• Stars
    star
    212
  • Rank 186,122 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created almost 11 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python wrapper for the OpenStreetMap API

osmapi

Build osmapi Coverage Version License

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

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 master 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. Re-build the documentation (make docs)
  4. Create a pull request to merge develop into master (make sure the tests pass!)
  5. Create a new release/tag on GitHub (on the master branch)
  6. The publication on PyPI happens via GitHub Actions on every tagged commit

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

More Repositories

1

openerz

OpenERZ is an open API to the waste collection of many different municipalities in Switzerland (e.g. Zurich, Basel, St. Gallen, Uster, Thalwil, Adliswil, Horgen etc.)
JavaScript
24
star
2

swissparlpy

Wrapper for the Swiss Parliament API for Python
Python
17
star
3

GFTPrototype

Google Fusion Tables Prototype
JavaScript
11
star
4

sruthi

SRU (Search/Retrieve via URL) client library for Python
Python
9
star
5

cabdriver

A little helper for taxi
JavaScript
7
star
6

travis-ping

Trigger Travis CI builds programmatically
Ruby
5
star
7

betty-botssi

A recipe bot
JavaScript
4
star
8

datatank-vagrant

Vagrant setup for The DataTank
PHP
4
star
9

csvtowikidata

Parse CSV file and add data from WikiData (Wikimedia Hackathon 2014)
Python
4
star
10

ancestors

Family tree gadget for Wikidata
JavaScript
3
star
11

tecdottir

API for weather stations of the Wasserschutzpolizei Zurich
JavaScript
3
star
12

goifer

goifer 🤤 is the glue code needed to extract information from Gever (Geschäftsverwaltungssystem)
Python
3
star
13

museumpy

MuseumPlus client for Python
Python
2
star
14

GFTExamples

Examples for Google Fusion Tables
PHP
2
star
15

covid-19-scraper-canton-be

COVID-19 case numbers for the canton Bern
Python
2
star
16

road-to-roam

Python
1
star
17

website-monitor

A simple monitor script for any change on a website
Python
1
star
18

try_git

1
star
19

schlaumeier

Slackbot for local area information of Zurich
JavaScript
1
star
20

covid-19-scraper-canton-ju

COVID-19 case numbers for the canton Jura
Python
1
star
21

hoerbert

Ein Skript um unter Linux Playlists für den Hörbert zu erstellen
Shell
1
star
22

learning-python

OpenTechSchool Python Beginners Workshop
Python
1
star
23

ckanext-graphql

GraphQL for CKAN
Python
1
star
24

open-power-system-timeseries

Python
1
star
25

janitor

A friendly slack bot for the maintenance of your building.
JavaScript
1
star
26

doing-data-science

Exercises from the book "Doing Data Science"
1
star
27

TrailDevilsXPl-2

Trail-Devils WebApp (X-Platform)
JavaScript
1
star
28

codeviz

A simple node application that shows code stats based on a GitHub organization
JavaScript
1
star
29

iphone-preview

Provides a simple iPhone preview using an image and an iframe
JavaScript
1
star
30

odi86.ruhoh.com

ruhoh static blog
Ruby
1
star