REST API¶
The RESTful API is created with FastAPI and psycopg and is provides low-level access to the database. The API (and database) is currently hosted with DigitalOcean. This REST API is mainly intended for web applications to query the database. If you are using LEDGER for data analysis we suggest using the Python Client.
Here, we provide a brief overview of the API endpoints. The table below summarizes the LEDGER API endpoints used to query actors and associated datasets. {actor_id} denotes a path parameter representing the unique identifier of an actor (e.g., country, state, province, or city) in the LEDGER database. Countries, states, and provinces use ISO3 codes, while cities use LOCODE.
| Endpoint | Description | Query Parameters |
|---|---|---|
/actor |
List all actors in the database. | — |
/actor/{actor_id}/parts |
List actors contained within another actor (e.g., states within a country). | type |
/actor/{actor_id}/gdp |
Return GDP time series for a given actor. | — |
/actor/{actor_id}/population |
Return population time series for a given actor. | — |
/actor/{actor_id}/energy_consumption |
Return energy consumption time series for a given actor. | — |
/actor/{actor_id}/targets |
Return emissions reduction targets associated with an actor. | — |
/actor/{actor_id}/emissions |
Return greenhouse gas emissions time series. Results can be filtered by gas species, sector classification, or datasource. | |
/sector |
returns emission sectors | |
/gwp |
returns global warming potential | |
/datasource |
returns global warming potential | |
For complete documentation please see the API documentation in ReDOC and Swagger format below.
ReDOC Documentation Swagger Documentation
Usage¶
The API provides endpoints to retrieve emissions and contextual data.
Example
The following returns all the actors in the database https://orca-app-5ivtt.ondigitalocean.app/api/v0/actor.