Skip to main content

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"

Metadata

Release files for openepi-client 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openepi-client 2.0.0
File Size Uploaded
openepi_client-2.0.0.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openepi-client 2.0.0
File Interpreter ABI Platform
openepi_client-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / openepi_client-2.0.0.tar.gz

Download URL openepi_client-2.0.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3d37b28bdc356f5f8b78ffd976389f82c92b45ae127e40a72b3a1eb18f77d33a
BLAKE2b-256 checksum
How to use checksums
0394c25ced0cf51274360a495f24cdbbd78fd73aac171308f69a3eed07201d08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2025.

Transparency log

Release files / openepi_client-2.0.0-py3-none-any.whl

Download URL openepi_client-2.0.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a497fbea9c544603d30707b3c9c403edfbe1734ba4e7fc75c413526f2cbb33bd
BLAKE2b-256 checksum
How to use checksums
47767d62ade2d6f546e74ccf3e4ca832390fea4d3905089182720ffe7acd0c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page