Package: openepi-client
openepi-clientA python client for accessing data from OpenEPI.
Can be installed from PyPI onhttps://pypi.org/project/openepi-client/Table of ContentsWeather DataSync usageAsync usageGeocodingSync usageAsync usageFlood predictionsSync usageAsync usageDeforestationSync usageAsync usageWeatherSync usagefromopenepi_clientimportGeoLocationfromopenepi_client.weatherimportWeatherClient# Getting the sunrise and sunset times for a locationsunrise_sunset=WeatherClient.get_sunrise(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Getting the weather forecast for a locationforecast=WeatherClient.get_location_forecast(geolocation=GeoLocation(lat=51.5074,lon=0.1278))Async usagefromopenepi_client.weatherimportAsyncWeatherClient# Getting the sunrise and sunset times for a locationsunrise_sunset=awaitAsyncWeatherClient.get_sunrise(lat=51.5074,lon=0.1278)# Getting the weather forecast for a locationforecast=awaitAsyncWeatherClient.get_location_forecast(lat=51.5074,lon=0.1278)# Searching for coordinates for a locationfeature_collection=awaitAsyncGeocodeClient.geocode(q="Kigali, Rwanda")GeocodingSync usagefromopenepi_client.geocodingimportGeocodeClient# Searching for the coordinates to a named placefeature_collection=GeocodeClient.geocode(q="Kigali, Rwanda")# Geocode with priority to a lat and lonfeature_collection=GeocodeClient.geocode(q="Kigali, Rwanda",lat=51.5074,lon=0.1278)# Reverse geocodefeature_collection=GeocodeClient.reverse_geocode(lat=51.5074,lon=0.1278)Async usagefromopenepi_client.geocodingimportAsyncGeocodeClient# Searching for coordinates for a locationfeature_collection=awaitAsyncGeocodeClient.geocode(q="Kigali, Rwanda")# Geocode with priority to a lat and lonfeature_collection=awaitAsyncGeocodeClient.geocode(q="Kigali, Rwanda",lat=51.5074,lon=0.1278)# Reverse geocodefeature_collection=awaitAsyncGeocodeClient.reverse_geocode(lat=51.5074,lon=0.1278)FloodSync usagefromopenepi_clientimportGeoLocation,BoundingBoxfromopenepi_client.floodimportFloodClient# Get the return period thresholds for a given geolocationthresholds=FloodClient.get_threshold(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get the return period thresholds for a given bounding boxthresholds=FloodClient.get_threshold(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))# Get a summary flood forecast for a given coordinatesummary=FloodClient.get_summary(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get a summary flood forecast for a given bounding boxsummary=FloodClient.get_summary(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))# Get a detailed flood forecast for a given coordinatedetailed=FloodClient.get_detailed(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get a detailed flood forecast for a given bounding boxdetailed=FloodClient.get_detailed(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))Async usagefromopenepi_clientimportGeoLocation,BoundingBoxfromopenepi_client.floodimportAsyncFloodClient# Get the return period thresholds for a given geolocationthresholds=awaitAsyncFloodClient.get_threshold(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get the return period thresholds for a given bounding boxthresholds=awaitAsyncFloodClient.get_threshold(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))# Get a summary flood forecast for a given coordinatesummary=awaitAsyncFloodClient.get_summary(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get a summary flood forecast for a given bounding boxsummary=awaitAsyncFloodClient.get_summary(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))# Get a detailed flood forecast for a given coordinatedetailed=awaitAsyncFloodClient.get_detailed(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get a detailed flood forecast for a given bounding boxdetailed=awaitAsyncFloodClient.get_detailed(bounding_box=BoundingBox(min_lat=4.764412,min_lon=22.0,max_lat=5.015732,max_lon=23.05))DeforestationSync usagefromopenepi_clientimportGeoLocation,BoundingBoxfromopenepi_client.deforestationimportDeforestationClient# Get the yearly forest cover loss within a river basin for a given geolocationforest_loss=DeforestationClient.get_basin(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get yearly forest cover loss for all river basins within the given bounding boxforest_loss=DeforestationClient.get_basin(bounding_box=BoundingBox(min_lat=30.909622,min_lon=28.850951,max_lat=-1.041395,max_lon=-2.840114))Async usagefromopenepi_clientimportGeoLocation,BoundingBoxfromopenepi_client.deforestationimportAsyncDeforestationClient# Get the return period thresholds for a given geolocationforest_loss=awaitAsyncDeforestationClient.get_basin(geolocation=GeoLocation(lat=51.5074,lon=0.1278))# Get yearly forest cover loss for all river basins within the given bounding boxforest_loss=awaitAsyncDeforestationClient.get_basin(bounding_box=BoundingBox(min_lat=30.909622,min_lon=28.850951,max_lat=-1.041395,max_lon=-2.840114))Updating the clientThe following commands are used to update the client types. The commands are run from the root of the project.poetryrundatamodel-codegen--urlhttps://api-test.openepi.io/weather/openapi.json--outputopenepi_client/weather/_weather_types.py--enum-field-as-literalall--output-model-typepydantic_v2.BaseModelpoetryrundatamodel-codegen--urlhttps://api-test.openepi.io/geocoding/openapi.json--outputopenepi_client/geocoding/_geocoding_types.py--enum-field-as-literalall--output-model-typepydantic_v2.BaseModelpoetryrundatamodel-codegen--urlhttps://api-test.openepi.io/flood/openapi.json--outputopenepi_client/flood/_flood_types.py--enum-field-as-literalall--output-model-typepydantic_v2.BaseModelpoetryrundatamodel-codegen--urlhttps://api-test.openepi.io/deforestation/openapi.json--outputopenepi_client/deforestation/_deforestation_types.py--enum-field-as-literalall--output-model-typepydantic_v2.BaseModel