A python library for interacting with the OpenEPI data
Project description
openepi-client
A python client for accessing data from OpenEPI. Can be installed from PyPI on https://pypi.org/project/openepi-client/
Table of Contents
Weather
Sync usage
from openepi_client import GeoLocation
from openepi_client.weather import WeatherClient
# Getting the sunrise and sunset times for a location
sunrise_sunset = WeatherClient.get_sunrise(geolocation=GeoLocation(lat=51.5074, lon=0.1278))
# Getting the weather forecast for a location
forecast = WeatherClient.get_location_forecast(geolocation=GeoLocation(lat=51.5074, lon=0.1278, alt=0))
Async usage
from openepi_client import GeoLocation
from openepi_client.weather import AsyncWeatherClient
# Getting the sunrise and sunset times for a location
sunrise_sunset = await AsyncWeatherClient.get_sunrise(geolocation=GeoLocation(lat=51.5074, lon=0.1278))
# Getting the weather forecast for a location
forecast = await AsyncWeatherClient.get_location_forecast(geolocation=GeoLocation(lat=51.5074, lon=0.1278, alt=0))
Geocoding
Sync usage
from openepi_client import GeoLocation
from openepi_client.geocoding import GeocodeClient
# Searching for the coordinates to a named place
feature_collection = GeocodeClient.geocode(q="Kigali, Rwanda")
# Geocode with priority to a lat and lon
feature_collection = GeocodeClient.geocode(q="Kigali, Rwanda", geolocation=GeoLocation(lat=51.5074, lon=0.1278))
# Reverse geocode
feature_collection = GeocodeClient.reverse_geocode(geolocation=GeoLocation(lat=51.5074, lon=0.1278))
Async usage
from openepi_client import GeoLocation
from openepi_client.geocoding import AsyncGeocodeClient
# Searching for coordinates for a location
feature_collection = await AsyncGeocodeClient.geocode(q="Kigali, Rwanda")
# Geocode with priority to a lat and lon
feature_collection = await AsyncGeocodeClient.geocode(q="Kigali, Rwanda", geolocation=GeoLocation(lat=51.5074, lon=0.1278))
# Reverse geocode
feature_collection = await AsyncGeocodeClient.reverse_geocode(geolocation=GeoLocation(lat=51.5074, lon=0.1278))
Global Forest Watch
Sync usage
from openepi_client.global_forest_watch import GlobalForestWatchClient
# Create an account
# Note that after doing this, you must verify your email and set a password before you can use your account
GlobalForestWatchClient().create_account(name="Your Name", email="your@mail.com")
# Create an API key
gfw = GlobalForestWatchClient(email="your@mail.com", password="your secret password")
response = gfw.create_api_key(alias="my-alias", organization="Example org", domains=["example.com"])
print(f"Your API key is: {response.api_key}")
gfw = GlobalForestWatchClient(api_key="your-api-key")
# List datasets
datasets = gfw.list_datasets()
# Get a specific dataset
dataset = gfw.get_dataset(dataset_id="<identifier>")
# Get the latest version of a dataset
latest_version = dataset.get_version(version = dataset.latest_version_id)
# List fields in a dataset version
fields = latest_version.fields()
for field in fields:
print(fields.description)
# List assets in a dataset version
assets_response = latest_version.assets()
# download all downloadable assets
for asset in assets_response.assets:
if asset.is_downloadable:
asset.download(to="<my_download_path>")
Updating the client
The following commands are used to update the client types. The commands are run from the root of the project.
poetry run datamodel-codegen --url https://api.openepi.io/geocoding/openapi.json --output openepi_client/geocoding/_geocoding_types.py --enum-field-as-literal all --output-model-type pydantic_v2.BaseModel --input-file-type "openapi"
poetry run datamodel-codegen --url https://api.openepi.io/flood/openapi.json --output openepi_client/flood/_flood_types.py --enum-field-as-literal all --output-model-type pydantic_v2.BaseModel --input-file-type "openapi"
poetry run datamodel-codegen --url https://api.openepi.io/deforestation/openapi.json --output openepi_client/deforestation/_deforestation_types.py --enum-field-as-literal all --output-model-type pydantic_v2.BaseModel --input-file-type "openapi"
poetry run datamodel-codegen --url https://api.openepi.io/soil/openapi.json --output openepi_client/soil/_soil_types.py --enum-field-as-literal all --output-model-type pydantic_v2.BaseModel --input-file-type "openapi"
poetry run datamodel-codegen --url https://api.openepi.io/crop-health/openapi.json --output openepi_client/crop_health/_crop_health_types.py --enum-field-as-literal all --output-model-type pydantic_v2.BaseModel --input-file-type "openapi"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openepi_client-2.0.0.tar.gz.
File metadata
- Download URL: openepi_client-2.0.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d37b28bdc356f5f8b78ffd976389f82c92b45ae127e40a72b3a1eb18f77d33a
|
|
| MD5 |
3f2c11a0a8a9d7fd0ed562d5e22071af
|
|
| BLAKE2b-256 |
0394c25ced0cf51274360a495f24cdbbd78fd73aac171308f69a3eed07201d08
|
Provenance
The following attestation bundles were made for openepi_client-2.0.0.tar.gz:
Publisher:
main-release.yml on openearthplatforminitiative/openepi-client-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openepi_client-2.0.0.tar.gz -
Subject digest:
3d37b28bdc356f5f8b78ffd976389f82c92b45ae127e40a72b3a1eb18f77d33a - Sigstore transparency entry: 629778416
- Sigstore integration time:
-
Permalink:
openearthplatforminitiative/openepi-client-py@1288b4ad4cfd9f20b3a079d15404b098415e753a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/openearthplatforminitiative
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-release.yml@1288b4ad4cfd9f20b3a079d15404b098415e753a -
Trigger Event:
push
-
Statement type:
File details
Details for the file openepi_client-2.0.0-py3-none-any.whl.
File metadata
- Download URL: openepi_client-2.0.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a497fbea9c544603d30707b3c9c403edfbe1734ba4e7fc75c413526f2cbb33bd
|
|
| MD5 |
88ce298a4a89b90b23eaecbde2741da1
|
|
| BLAKE2b-256 |
47767d62ade2d6f546e74ccf3e4ca832390fea4d3905089182720ffe7acd0c3b
|
Provenance
The following attestation bundles were made for openepi_client-2.0.0-py3-none-any.whl:
Publisher:
main-release.yml on openearthplatforminitiative/openepi-client-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openepi_client-2.0.0-py3-none-any.whl -
Subject digest:
a497fbea9c544603d30707b3c9c403edfbe1734ba4e7fc75c413526f2cbb33bd - Sigstore transparency entry: 629778424
- Sigstore integration time:
-
Permalink:
openearthplatforminitiative/openepi-client-py@1288b4ad4cfd9f20b3a079d15404b098415e753a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/openearthplatforminitiative
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-release.yml@1288b4ad4cfd9f20b3a079d15404b098415e753a -
Trigger Event:
push
-
Statement type: