DENGPS Maps API

Search places, look up what is at a coordinate, find points of interest, read posted speed limits and road hazards, send and read driver reports, and get directions. Every call names a country with cc and is answered from that country's data only. Available now: Ghana (gh), Togo (tg), Cote d'Ivoire (ci), Burkina Faso (bf). Data is © OpenStreetMap contributors, ODbL, and the vector tiles are © OpenMapTiles (CC-BY). Anything you show from them needs both credits.

Authentication

Send your key in the X-Api-Key header (or ?key= for quick tests; headers are safer because URLs end up in logs). Keys are issued from the DENGPS console under Maps API keys and are shown once. For use in a browser page, a key is tied to a list of allowed origins; calls from other origins get 403. A key can also be limited to chosen countries. The DENGPS map itself calls the API from its own origin without a key and is limited per IP address.

curl -H "X-Api-Key: dgm_..." "https://gps.dendat.ai/api/maps/v1/search?cc=gh&q=korle%20bu"
const r = await fetch('https://gps.dendat.ai/api/maps/v1/search?cc=gh&q=korle%20bu', {headers: {'X-Api-Key': KEY}});
const {results} = await r.json();

Listing driver reports (GET /reports) always needs a key. Sending a report and voting need a key or a same-origin call.

Rate limits

CallerLimit
API keyThe per-minute number set on the key (10 to 3000). Counted per worker process, so treat it as a ceiling, not a meter.
DENGPS map, no keyPer IP address per minute: 90 search, 20 route, 240 everything else.
Driver reports12 new reports per hour per reporter, and 8 new reports per 10 minutes in one 2 km area.

Over a limit you get 429, a retry_after field and a Retry-After header in seconds. Responses are cached for 60 seconds (Cache-Control); route responses are not cached.

Errors

Every error is JSON: {"ok": false, "error": "..."}.

CodeMeaning
400A parameter is missing or malformed (for example a bbox that is too large).
401No key where one is required, or the key is invalid or revoked.
403The browser origin is not allowed for this key, the key is not licensed for that country, or you tried to mark your own report gone.
404Unknown country, place, or an expired report. A point outside the country on reverse.
422A point is outside the country, or a route crosses a border.
429Rate limit reached. Wait retry_after seconds.
502, 503The routing engine or a database is unavailable. Retry later.

Endpoints

All paths start with /api/maps/v1. bbox is always west,south,east,north in degrees; points are lat,lon.

CallParametersReturns
GET /regionsnoneCountries available, bounds, tile size in bytes, build date, what is ready.
GET /searchcc, q (2+ characters), near=lat,lon, category, limit (max 25)Places ranked by text match, importance and distance from near: id, name, category, kind, lat, lon, address, city, and distance_m when near is given.
GET /reversecc, lat, lonThe nearest named place and the nearest town. 404 if the point is outside the country.
GET /place/{cc}/{id}noneOne place with phone, website and hours when OpenStreetMap has them, plus about: a plain-language description written only from those fields.
GET /poiscc, bbox (at most 3 degrees), z, optional cat, limit (max 600)GeoJSON points for hospitals, police, fire, fuel, pharmacies, banks, ATMs, schools, hotels, food, government offices, worship, transport and landmarks, thinned by zoom.
GET /nearbycc, lat, lon, cat (comma list), limit (max 20), radius_km (max 60)The nearest places of each kind to a point, with distance_m.
GET /explorecc, tile, near, radius_km, sort, open_now, limit, offsetA category around a point. GET /tiles lists the tile keys. GET /whatshere describes a point.
GET /safetycc, bbox (at most 1 degree)GeoJSON points: speed cameras, red-light cameras, speed bumps, rumble strips, level crossings and toll booths from OpenStreetMap, plus live driver reports (source: "driver").
GET /limitscc, bbox (at most 0.3 degree)GeoJSON lines for roads with a posted limit (kmh). Roads without a tag are absent, not guessed.
GET /reportscc, bbox (at most 2 degrees), kind (comma list), cluster=1, limit (max 500). Key required.Live driver reports in the box, see below.
POST /reportsJSON cc, kind, lat, lonSend a driver report.
POST /reports/{id}/voteJSON v: still or goneConfirm a report or say it is gone.
GET /routecc, from, to, mode, via, avoidDirections, see below.
GET /companiescc, bbox (at most 1 degree), optional categoryGeoJSON points for businesses and services in view: OpenStreetMap businesses, approved business entries and web-found entries, each with a source.
curl -H "X-Api-Key: $KEY" "https://gps.dendat.ai/api/maps/v1/nearby?cc=gh&lat=5.6037&lon=-0.187&cat=hospital,police&limit=3"

const near = await (await fetch(`https://gps.dendat.ai/api/maps/v1/nearby?cc=gh&lat=5.6037&lon=-0.187&cat=fuel`, {headers: {'X-Api-Key': KEY}})).json();
console.log(near.results.fuel[0].name, near.results.fuel[0].distance_m);

Driver reports

Fixed cameras and limits come from OpenStreetMap volunteers. Police checks, speed traps and similar are driver reports: unverified, labelled as such, and they expire. A report kind decides how long it lives.

kindStays up
police, crash, stopped2 hours
speed_trap, speed_camera_mobile, checkpoint3 hours
hazard6 hours
flood, broken_traffic_light12 hours
roadwork24 hours
pothole72 hours

A confirmation extends a report, never beyond twice its normal life. A "gone" vote shortens it. A same-kind report within 150 m of a live one counts as a confirmation. Votes are weighted by a per-reporter trust score that starts equal for everyone; reports from bursts and low-trust senders are hidden from others. The reporter is only ever a salted hash.

curl -H "X-Api-Key: $KEY" "https://gps.dendat.ai/api/maps/v1/reports?cc=gh&bbox=-0.35,5.45,-0.05,5.75&cluster=1"
{
  "ok": true, "count": 1, "note": "Driver reports are unverified and expire on their own...",
  "reports": [{"id": 17, "kind": "police", "label": "Police", "lat": 5.6, "lon": -0.2,
    "age_min": 12, "confirmed_by": 3, "expires_in_min": 95, "verified": false,
    "text": "Police reported 12 min ago, confirmed by 3 drivers. Unverified; this expires on its own in about 95 min."}],
  "clusters": [{"lat": 5.6, "lon": -0.2, "n": 1, "kinds": {"police": 1}, "newest_min": 12, "ids": [17]}]
}

fetch('https://gps.dendat.ai/api/maps/v1/reports', {method: 'POST', headers: {'X-Api-Key': KEY, 'Content-Type': 'application/json'},
  body: JSON.stringify({cc: 'gh', kind: 'pothole', lat: 5.6037, lon: -0.187})});

Routing

GET /route?cc=gh&from=5.6037,-0.1870&to=6.6885,-1.6244&mode=drive

ParameterMeaning
modedrive (default), walk or bike.
viaUp to three stops between the ends as lat,lon;lat,lon. Each must be inside the country. With stops you get one route; without, up to three (drive).
avoidComma list: tolls, highways (drive only).

Each route has distance_m, duration_s, has_toll, a GeoJSON geometry and a steps list (instruction, street, distance, time, location, spoken text). Driving routes also carry limits (posted limit by distance along the route, null where unmapped) and alerts (cameras, bumps, crossings, tolls, school zones and live driver reports on the route, in order, each with at_m, the distance from the start).

Both ends must be inside the named country. Times use road speeds from the map. A drive route also carries a traffic object: measured delay is added to duration_s only where enough drivers shared speeds in the last 15 minutes, and has_data is false when there was none.

const j = await (await fetch(`https://gps.dendat.ai/api/maps/v1/route?cc=gh&from=5.6037,-0.187&to=6.6885,-1.6244&avoid=tolls`, {headers: {'X-Api-Key': KEY}})).json();
console.log(j.routes[0].distance_m / 1000, 'km', j.routes[0].alerts.length, 'alerts');

Offline pack

Not key gated, so the app can fetch them. GET /maps/pack/{cc}/manifest.json lists the pack, its version, and each file's size and sha256; compare version to know whether an update exists. Files: /maps/tiles/{cc}.pmtiles (the map), /maps/pack/{cc}/places.json (name index for search), and pois.json, safety.json, limits.json, explore.json. Offline routing is not available.

Embedding the map

Tiles are one PMTiles file per country at /maps/tiles/{cc}.pmtiles with HTTP range support, and a ready MapLibre style at /maps/style/{cc}.json?theme=light (or dark). A complete page, using the MapLibre and PMTiles builds this server already hosts (set maplibregl.setWorkerUrl to maplibre-gl-csp-worker.js if your page has a strict content security policy):

<link rel="stylesheet" href="https://gps.dendat.ai/static/vendor/maplibre/maplibre-gl.css">
<script src="https://gps.dendat.ai/static/vendor/maplibre/maplibre-gl-csp.js"></script>
<script src="https://gps.dendat.ai/static/vendor/maplibre/pmtiles.js"></script>
<div id="map" style="height:420px"></div>
<script>
  maplibregl.addProtocol('pmtiles', new pmtiles.Protocol().tile);
  const map = new maplibregl.Map({container: 'map', style: 'https://gps.dendat.ai/maps/style/gh.json', center: [-0.2, 5.6], zoom: 11});
  fetch('https://gps.dendat.ai/api/maps/v1/pois?cc=gh&bbox=-0.3,5.5,-0.1,5.7&z=13', {headers: {'X-Api-Key': 'dgm_...'}})
    .then(r => r.json()).then(fc => fc.features.forEach(f =>
      new maplibregl.Marker().setLngLat(f.geometry.coordinates).setPopup(new maplibregl.Popup().setText(f.properties.name)).addTo(map)));
</script>

Or link straight to the map: /map?ll=5.6037,-0.1870&z=15 opens a location, and /map?from=5.6037,-0.1870&to=6.6885,-1.6244&mode=drive opens a route. Keep the OpenStreetMap and OpenMapTiles credits visible on any map you show.

SDK: one script tag

The loader brings our map engine, style, tiles and fonts. The map it returns is a MapLibre GL map, so markers, popups, layers, flyTo and fitBounds work as usual. Tiles, style and fonts need no key; search, reverse and routes need a key that lists your site's origin.

<div id="map" style="height:420px"></div>
<script src="https://gps.dendat.ai/sdk/v1/dengps-maps.js"></script>
<script>
  DENGPS.key = 'dgm_...';
  DENGPS.map('map', {center: [-0.19, 5.6], zoom: 12, theme: 'light'}).then(function (map) {
    DENGPS.marker([-0.187, 5.6037], {color: '#f5b400', label: 'A'}).addTo(map);
    DENGPS.geocoder(map, {placeholder: 'Search places', onSelect: function (p) { console.log(p.name, p.lat, p.lon); }});
  });
  DENGPS.search('Accra Mall').then(function (j) { console.log(j.results); });
  DENGPS.route([[5.6037, -0.187], [6.6885, -1.6244]], {mode: 'drive'}).then(function (j) { console.log(j.routes[0]); });
</script>

DENGPS.geocoder adds a search box with suggestions, flies to the pick and drops a marker (turn off with flyTo: false, marker: false). DENGPS.marker takes [lon, lat] and returns a normal marker. Neither needs a stylesheet of its own. Your page's Content-Security-Policy needs:

script-src  https://gps.dendat.ai
style-src   https://gps.dendat.ai
connect-src https://gps.dendat.ai
worker-src  blob:
img-src     data: blob:

Compatible geocoding and directions

For code written against the common geocoding v5 and directions v5 response shapes: change the base URL to https://gps.dendat.ai/api/maps/v1/compat and use a DENGPS key as access_token (or X-Api-Key). Same keys, origin rules and rate limits as the rest of the API.

CallNotes
GET /compat/geocoding/v5/places/{query}.jsonFeatureCollection; each feature has id, place_type, text, place_name, center, geometry, properties, context. Honours proximity=lon,lat, limit (up to 10), country, bbox, types (poi, address, place, locality, neighborhood). The dataset segment can be any name, so existing paths keep working.
GET /compat/geocoding/v5/places/{lon},{lat}.jsonReverse: nearest place of interest, nearest street, town and country, most specific first.
GET /compat/directions/v5/{profile}/{lon,lat;lon,lat}driving, walking, cycling; 2 to 5 points. Returns code, routes (distance m, duration s, geometry, legs[].steps[].maneuver with type, modifier, instruction, location) and waypoints. Honours geometries (polyline, polyline6, geojson), steps, alternatives, overview=false.
curl 'https://gps.dendat.ai/api/maps/v1/compat/directions/v5/driving/-0.187,5.6037;-1.6244,6.6885?geometries=geojson&steps=true&access_token=dgm_...'

Limits, plainly: coverage is the countries listed at the top of this page, nothing outside them, and a route cannot cross a border. There is no satellite or aerial imagery, only the drawn map. Not supported and ignored: language, annotations, voice and banner instructions, exclude; overview=simplified returns the full line; duration uses road speeds, not live traffic. Errors carry code and message.

What the data is not

Live traffic exists only where enough drivers are navigating; a road with no traffic colour has no data. A missing camera is not proof there is none, because only volunteers' mapped cameras are included. A missing speed limit means the road has no mapped limit, not that there is none. Police and speed-trap reports are drivers' unverified reports and expire. Do not build a feature that tells people where enforcement is on the strength of them.