Skip to main content

Python wrapper for the OSM API

Project description

osmapi

Build osmapi Coverage Version License

Python wrapper for the OSM API (requires Python >= 3.7)

Installation

Install osmapi from PyPi by using pip:

pip install osmapi

Documentation

The documentation is generated using pdoc and can be viewed online.

The build the documentation locally, you can use

make docs

This project uses GitHub Pages to publish its documentation. To update the online documentation, you need to re-generate the documentation with the above command and update the gh-pages branch of this repository.

Examples

To test this library, please create an account on the development server of OpenStreetMap (https://api06.dev.openstreetmap.org).

Read from OpenStreetMap

import osmapi
api = osmapi.OsmApi()
print(api.NodeGet(123))
# {u'changeset': 532907, u'uid': 14298,
# u'timestamp': u'2007-09-29T09:19:17Z',
# u'lon': 10.790009299999999, u'visible': True,
# u'version': 1, u'user': u'Mede',
# u'lat': 59.9503044, u'tag': {}, u'id': 123}

Constructor

import osmapi
api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = "you", password = "***")
api = osmapi.OsmApi(username = "you", passwordfile = "/etc/mypasswords")
api = osmapi.OsmApi(passwordfile = "/etc/mypasswords") # if only the passwordfile is specified, the credentials on the first line of the file will be used

Note: Each line in the password file should have the format user:password

Write to OpenStreetMap

import osmapi
api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = u"metaodi", password = u"*******")
api.ChangesetCreate({u"comment": u"My first test"})
print(api.NodeCreate({u"lon":1, u"lat":1, u"tag": {}}))
# {u'changeset': 532907, u'lon': 1, u'version': 1, u'lat': 1, u'tag': {}, u'id': 164684}
api.ChangesetClose()

Note

Scripted imports and automated edits should only be carried out by those with experience and understanding of the way the OpenStreetMap community creates maps, and only with careful planning and consultation with the local community.

See the Import/Guidelines and Automated Edits/Code of Conduct for more information.

Development

If you want to help with the development of osmapi, you should clone this repository and install the requirements:

pip install -r requirements.txt
pip install -r test-requirements.txt

After that, it is recommended to install the flake8 pre-commit-hook:

flake8 --install-hook

Tests

To run the tests use the following command:

make test

Release

To create a new release, follow these steps (please respect Semantic Versioning):

  1. Adapt the version number in osmapi/__init__.py
  2. Update the CHANGELOG with the version
  3. Create a pull request to merge develop into master (make sure the tests pass!)
  4. Create a new release/tag on GitHub (on the master branch)
  5. The publication on PyPI happens via GitHub Actions on every tagged commit
  6. Re-build the documentation (see above) and copy the generated files to the gh-pages branch

Attribution

This project was orginally developed by Etienne Chové. This repository is a copy of the original code from SVN (http://svn.openstreetmap.org/applications/utils/python_lib/OsmApi/OsmApi.py), with the goal to enable easy contribution via GitHub and release of this package via PyPI.

See also the OSM wiki: http://wiki.openstreetmap.org/wiki/Osmapi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osmapi-2.0.2.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

osmapi-2.0.2-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file osmapi-2.0.2.tar.gz.

File metadata

  • Download URL: osmapi-2.0.2.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for osmapi-2.0.2.tar.gz
Algorithm Hash digest
SHA256 ec0be6550b86bdb6369fd2f766563c22875f75a516a2526bfa0c2950d3c1feb2
MD5 2c5844a43ce25f5bb4f1f11e5e13118c
BLAKE2b-256 e909ca16d9a2b1977113756469828c228f686d02b352c2173a22eb56d5dbf706

See more details on using hashes here.

File details

Details for the file osmapi-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: osmapi-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 41.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for osmapi-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e32bb0e1ea488d605c121edc125c4614aafd887d3dcccf59f76e6daa22767fd
MD5 06bd78afe2bca593dbc3e9d25324ee7c
BLAKE2b-256 898765e90193d5e51812ccdc1e0b78469973b4aa8f96020710a0ad593b743284

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page