Skip to main content

Python wrapper for the OSM API

Project description

|Build| |Coverage| |Version| |Downloads| |License|

Python wrapper for the OSM API

Installation

Install osmapi simply by using pip:

pip install osmapi

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:

nosetests --verbose

By using tox you can even run the tests against different versions of python (2.6, 2.7, 3.2 and 3.3):

tox

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.

Documentation

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

The build the documentation locally, you can use

pdoc --html osmapi.OsmApi # create HTML file

Examples

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="api06.dev.openstreetmap.org", username = "you", password = "***")
api = osmapi.OsmApi(username = "you", passwordfile = "/etc/mypasswords")
api = osmapi.OsmApi(passwordfile = "/etc/mypasswords") # username will be first line username

Note: The password file should have the format user:password

Write to OpenStreetMap

import osmapi
api = osmapi.OsmApi(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()

Attribution

This project was orginally developed by Etienne Chove. 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-0.6.0.tar.gz (13.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: osmapi-0.6.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for osmapi-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2b1703e98360c6c47e6d8c380630118b215fbd270f8a2e32de6d5caeb309beb9
MD5 ade4fc22215c60d4bdb8057c813f2813
BLAKE2b-256 686520a546b31a8748549da5f52a35de1b29e780ef9955b3430ef71d6e0424a5

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