ohsome API
September 15, 2026 ยท View on GitHub
ohsome API
The ohsome API is a generic web API for in-depth analysis of OpenStreetMap (OSM) data with a focus on its history. It allows to get aggregated statistics about the evolution of OSM data itself and about the contributors behind the data. Furthermore, data extraction methods are provided to access the historic development of individual OSM features.
Migration from ohsome API v1
Important
This repository is for ohsome API version 2, a complete rewrite of the ohsome API, including a new database backend.
See our migration guide for the differences between the versions and how to upgrade to the new version.
Using the ohsome API
To make your life easier, we already have a running ohsome API instance on our servers, where you can send your requests to analyze the history of the OpenStreetMap data. This instance is publicly accessible under the following URL:
- https://api.heigit.org/ohsome-api/v2-rc (release candidate for v2)
If you need further information, visit these sites:
Development Setup
Requirements:
We use:
pytestfor unit testsrufffor static code analysistyfor static type checksprekfor pre-commit hooks
Initial Setup
uv sync
uv run prek install
uv run pytest
Configuration
Copy .env.sample to .env and change content to provide credentials to an ohsomedb.
set -a; source .env; set +a
Logging
Logging is configured in src/ohsome_api/log_config.yaml.
It is possible to provide a custom log config YAML file which follows the logging config dictschema of Python by setting the environment variable OHSOME_API__LOG_CONFIG.
The log level can be set independently of the log config by setting the environment variable OHSOME_API__LOG_LEVEL to one of the log levels of Python:
export OHSOME_API__LOG_LEVEL=DEBUG
Debugging
To log the SQL query, arguments and the execution plan turn on debug logging (see above) and set the environment variable OHSOME_API__OHSOMEDB__DEBUG to True:
export OHSOME_API__LOG_LEVEL=DEBUG
export OHSOME_API__OHSOMEDB__DEBUG=True
Run Development Server
uv run fastapi dev
Be aware that this method does not use the production ASGI server and behaves differently in some cases.