nim-openstreetmap
- OpenStreetMap API Lib for Nim, Async & Sync, Pull Requests welcome.
Install
nimble install openstreetmap
Use
import openstreetmap
# Sync client.
let osm_client = OSM(timeout: 9, username: "user", password: "pass", use_prod_server: true, proxy: nil)
echo $osm_client.get_capabilities()
echo $osm_client.get_bounding_box(90.0, -90.0, 90.0, -90.0)
echo $osm_client.get_permissions()
echo $osm_client.get_changeset(61972594)
echo $osm_client.get_changeset_download(61972594)
echo $osm_client.get_changesets_bbox(90.0, -90.0, 90.0, -90.0)
echo $osm_client.get_changesets_open(true)
echo $osm_client.get_changesets_cid(@[61972594])
echo $osm_client.get_trackpoints(90.0, -90.0, 90.0, -90.0, 1)
echo $osm_client.get_notes(90.0, -90.0, 90.0, -90.0, limit=2)
echo $osm_client.get_notes_search(q="Argentina", limit=2)
# Async client.
proc test {.async.} =
let
osm_client = AsyncOSM(timeout: 9, username: "user", password: "pass", use_prod_server: true, proxy: nil)
async_resp = await osm_client.get_capabilities()
echo $async_resp
waitFor(test())
# Check the Docs for more API Calls...
API
- Check the OpenStreetMap Wiki, the Lib is a 1:1 copy of the official Docs.
- This Library uses API Version
0.6
from Year2018
. - Each proc links to the official OSM API docs.
- All procs should return an XML Object
PDocument
. - The order of the procs follows the order on the OSM Wiki.
- The naming of the procs follows the naming on the OSM Wiki.
- The errors on the procs follows the errors on the OSM Wiki.
- The
limit
key islimit: range[1..10000] = 100
as documented on the OSM Wiki. - API Calls that use HTTP
GET
start withget_*
. - API Calls that use HTTP
POST
start withpost_*
. - API Calls that use HTTP
PUT
start withput_*
. - API Calls that use HTTP
DELETE
start withdelete_*
. - API Calls use the DoNotTrack HTTP Header.
- The
timeout
argument is on Seconds. - OpenStreetMap API limits the length of all key and value strings to a maximum of 255 characters.
- For Proxy support define a
OSM.proxy
orAsyncOSM.proxy
ofProxy
type. - No OS-specific code, so it should work on Linux, Windows and Mac. Not JS.
- Run the module itself for an Example.
Support
All OpenStreetMap API is supported, except 2 API calls:
- https://wiki.openstreetmap.org/wiki/API_v0.6#Uploading_traces
- https://wiki.openstreetmap.org/wiki/API_v0.6#Redaction:_POST_.2Fapi.2F0.6.2F.5Bnode.7Cway.7Crelation.5D.2F.23id.2F.23version.2Fredact.3Fredaction.3D.23redaction_id
FAQ
- How to Edit the OpenStreetMap using this lib ?.
You must provide a valid active OpenStreetMap User and Password.
- This works without SSL ?.
No.
- This works with Asynchronous code ?.
Yes.
- This works with Synchronous code ?.
Yes.
- This requires API Key or Login ?.
- This requires Credit Card or Payments ?.
No.
- Why is slow to read data ?.
Use Overpass for Reading. This is optimized for Writing speed.
- How to Search by Name ?.
- Can I use the OpenStreetMap data ?.
Yes. You MUST give Credit to OpenStreetMap Contributors!.
- Can I use a Sandbox fake server for testing purposes ?.
Yes.
Set OSM.use_prod_server
or AsyncOSM.use_prod_server
of bool
type,
true
to use "https://api.openstreetmap.org/api/0.6/"
,
false
to use "https://master.apis.dev.openstreetmap.org/api/0.6/"
.
Requisites
- None.