Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: ["main"]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Sync dependencies
run: uv sync --group dev --frozen
- name: Lint
run: uv run ruff check
- name: Format
run: uv run ruff format --check
- name: Type check
run: uv run ty check
- name: Tests
run: uv run pytest tests/ --import-mode importlib
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ pip-log.txt
docs/_build/
Pipfile.lock
venv/
.venv/
.tox
.ruff_cache/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,26 @@ Overpass API python wrapper
API](http://wiki.openstreetmap.org/wiki/Overpass_API) for Python.

![shell recording](assets/overpass-demo.gif)
![CI](https://github.com/mvexel/overpass-api-python-wrapper/actions/workflows/ci.yml/badge.svg)

Install it
==========

`pip install overpass`

## Development

This project targets Python 3.11-3.13 and uses `mise` + `uv` for the toolchain.

```bash
mise install
uv sync --group dev
uv run ruff check
uv run ruff format
uv run ty check
uv run pytest tests/ --import-mode importlib
```

## Usage

### `API()` constructor
Expand Down
84 changes: 4 additions & 80 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,82 +1,9 @@
Overpass API python wrapper
===========================
Deprecated README.rst
=====================

.. image:: https://github.com/mvexel/overpass-api-python-wrapper/workflows/CI/badge.svg
:target: https://github.com/mvexel/overpass-api-python-wrapper/actions?query=workflow%3ACI
This file is deprecated. Please use ``README.md`` instead.


This is a thin wrapper around the OpenStreetMap `Overpass
API <http://wiki.openstreetmap.org/wiki/Overpass_API>`__.


|Build Status|

Install it
==========

``pip install overpass``

Usage
-----

Simplest example:

.. code:: python

import overpass
api = overpass.API()
response = api.get('node["name"="Salt Lake City"]')

``response`` will be a dictionary representing the JSON output you would
get `from the Overpass API
directly <https://overpass-api.de/output_formats.html#json>`__.

Note that the Overpass query passed to ``get()`` should not contain any
``out`` or other meta statements.

Another example:

.. code:: python

>>> print [(
... feature['properties']['name'],
... feature['id']) for feature in response["features"]]
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637)]

You can find more examples in the ``examples/`` directory of this
repository.

Response formats
~~~~~~~~~~~~~~~~

You can set the response type of your query using ``get()``\ ’s
``responseformat`` parameter to GeoJSON (``geojson``, the default),
plain JSON (``json``), CSV (``csv``), and OSM XML (``xml``).

.. code:: python

response = api.get('node["name"="Salt Lake City"]', responseformat="xml")

Parameters
~~~~~~~~~~

The API object takes a few parameters:

``endpoint``
^^^^^^^^^^^^

The default endpoint is ``https://overpass-api.de/api/interpreter`` but
you can pass in another instance:

.. code:: python

api = overpass.API(endpoint=https://overpass.myserver/interpreter)

``timeout``
^^^^^^^^^^^

The default timeout is 25 seconds, but you can set it to whatever you
want.
The Markdown version is the canonical documentation and is kept up to date.

.. code:: python

Expand Down Expand Up @@ -139,6 +66,3 @@ Where did the CLI tool go?
~~~~~~~~~~~~~~~~~~~~~~~~~~

The command line tool was deprecated in version 0.4.0.

.. |Build Status| image:: https://travis-ci.org/mvexel/overpass-api-python-wrapper.svg?branch=master
:target: https://travis-ci.org/mvexel/overpass-api-python-wrapper
3 changes: 3 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
python = "3.11"
uv = "latest"
571 changes: 0 additions & 571 deletions poetry.lock

This file was deleted.

70 changes: 53 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,62 @@
[tool.poetry]
[project]
name = "overpass"
version = "0.7.2"
description = "A Python interface to the OpenStreetMap Overpass API"
authors = ["Martijn van Exel <m@rtijn.org>"]
license = "Apache-2.0"
readme = "README.md"
homepage = "https://github.com/mvexel/overpass-api-python-wrapper"
packages = [{ include = "overpass" }]
requires-python = ">=3.11,<3.14"
license = { text = "Apache-2.0" }
authors = [{ name = "Martijn van Exel", email = "m@rtijn.org" }]
keywords = ["openstreetmap", "overpass", "wrapper"]
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Utilities",
]
dependencies = [
"osm2geojson>=0.2.5",
"requests>=2.32.3",
]

[project.urls]
Homepage = "https://github.com/mvexel/overpass-api-python-wrapper"
Repository = "https://github.com/mvexel/overpass-api-python-wrapper"

[tool.poetry.dependencies]
python = ">3.9, <3.12"
osm2geojson = "^0.2.5"
requests = "^2.32.3"
[dependency-groups]
dev = [
"pytest>=7.4.0",
"geojson>=3.1.0",
"requests-mock>=1.12.1",
"deepdiff>=7.0.1",
"ruff>=0.6.0",
"ty>=0.0.9",
]

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
geojson = "^3.1.0"
requests-mock = { extras = ["fixtures"], version = "^1.12.1" }
deepdiff = "^7.0.1"
tox = "^4.17.1"
[tool.hatch.build.targets.wheel]
packages = ["overpass"]

[tool.ruff]
line-length = 100
target-version = "py311"

[tool.ruff.lint]
select = ["E", "F", "I"]

[tool.ruff.format]
quote-style = "double"

[tool.ty.environment]
python-version = "3.11"

[tool.ty.src]
include = ["overpass", "tests"]

[tool.pytest.ini_options]
markers = ["integration: network-dependent tests"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling>=1.25.0"]
build-backend = "hatchling.build"
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

25 changes: 0 additions & 25 deletions setup.py

This file was deleted.

5 changes: 5 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from typing import Tuple, Union

import geojson
import os

import pytest
from deepdiff import DeepDiff

Expand Down Expand Up @@ -52,10 +54,13 @@ def test_geojson(
assert len(osm_geo["features"]) > length


@pytest.mark.integration
def test_multipolygon():
"""
Test that multipolygons are processed without error
"""
if not os.getenv("RUN_NETWORK_TESTS"):
pytest.skip("requires live Overpass API; set RUN_NETWORK_TESTS=1")
api = overpass.API()
api.get("rel(11038555)", verbosity="body geom")

Expand Down
16 changes: 0 additions & 16 deletions tox.ini

This file was deleted.

Loading
Loading