N-Ways
Developer docsRoutes

Routes

Routes for every way of travelling, the route matrix and route optimisation.

On this page
Note:

Send your key as key=YOUR_API_KEY on the address, or in the X-NWays-Api-Key header. API keys

Base address: https://nways.ng/maps/v1

A route, with up to 25 intermediates

POST https://nways.ng/maps/v1/routes/compute

Drive, van, okada (motorbike taxi; keeps to okada bans, walks past a ban area's edge), motorbike (your own) and dispatch (couriers' bikes: exempt from passenger-okada bans), keke and danfo (keep to their bans), walk, bicycle, boat (passenger boats and jetties) and train. Postcodes route to the building's best entrance; where the road stops short of the door the route says where to stop and how to finish (lastMile); tolls in their currencies, border crossings, gated estates, bans avoided with their sources. fields= picks fields of each route. Reasons: MODE_INVALID, LANG_INVALID, ROUTING_PREFERENCE_INVALID, TOO_MANY_INTERMEDIATES, INTERMEDIATES_NOT_SUPPORTED, AVOID_INVALID, TOLL_VEHICLE_INVALID, LAST_MILE_INVALID, ACCESS_INVALID, WAYPOINT_INVALID, POSTCODE_INVALID, POSTCODE_NOT_FOUND, GHANAPOST_INVALID, GHANAPOST_NOT_FOUND, PLUSCODE_INVALID, NO_ROUTE, NO_ROAD_ROUTE, ROUTE_TOO_FAR, ROUTING_UNAVAILABLE, OKADA_BANNED_ORIGIN, OKADA_BANNED_DESTINATION, OKADA_BANNED_ROUTE, KEKE_BANNED_*, DANFO_BANNED_*, MOTORBIKE_BANNED_*, ROUTING_UNAVAILABLE (503).

Parameters

NameInTypeDescription
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).

Request body

FieldTypeDescription
originWaypointRequired. Exactly one of lat and lng, postcode (NIPOST: routes to its best entrance), ghanaPost, or plusCode (full, or short with a town after it).
origin.latnumber
origin.lngnumber
origin.postcodestring
origin.ghanaPoststring
origin.plusCodestring
origin.headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
destinationWaypointRequired. Exactly one of lat and lng, postcode (NIPOST: routes to its best entrance), ghanaPost, or plusCode (full, or short with a town after it).
destination.latnumber
destination.lngnumber
destination.postcodestring
destination.ghanaPoststring
destination.plusCodestring
destination.headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
intermediatesWaypoint[]At most 25 items.
intermediates[].latnumber
intermediates[].lngnumber
intermediates[].postcodestring
intermediates[].ghanaPoststring
intermediates[].plusCodestring
intermediates[].headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
modestringOne of: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle, boat, train. Default: drive.
alternativesbooleanUp to 2 more routes (no intermediates). Default: false.
routingPreferencestringOne of: traffic_unaware, traffic_aware. Default: traffic_unaware.
departAtstring (date-time)
avoidstring[]
langstringOne of: en, fr, pt.
tollVehiclestringToll tariff class (van: bus). One of: car, suv, bus, truck.
accessstringTrain and boat trips: to and from stations and jetties. One of: walk, okada, drive.
lastMilestringOne of: walk, okada.
allowBansstring[]Unconfirmed ban ids (from unconfirmedBans) to route through anyway.
faresbooleanAdd fare estimates to each route (advanced SKU). Default: false.
cURL
curl -X POST "https://nways.ng/maps/v1/routes/compute" \
  -H "X-NWays-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin":{"lat":6.4474,"lng":3.472},"destination":{"postcode":"LA08A09DB10"},"mode":"drive","routingPreference":"traffic_aware"}'
JavaScript
const res = await fetch('https://nways.ng/maps/v1/routes/compute', {
  method: 'POST',
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "origin": {
      "lat": 6.4474,
      "lng": 3.472
    },
    "destination": {
      "postcode": "LA08A09DB10"
    },
    "mode": "drive",
    "routingPreference": "traffic_aware"
  }),
})
const data = await res.json()
Python
import os
import requests

res = requests.post(
    "https://nways.ng/maps/v1/routes/compute",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    json={"origin": {"lat": 6.4474, "lng": 3.472}, "destination": {"postcode": "LA08A09DB10"}, "mode": "drive", "routingPreference": "traffic_aware"},
    timeout=10,
)
data = res.json()

Response

Routes

FieldTypeDescription
routesRoute[]Required.
routes[].distanceMnumberRequired.
routes[].durationSnumberRequired.
routes[].staticDurationSnumberRequired. Without live traffic
routes[].trafficDelaySnumberRequired. What traffic and incidents add now (traffic_aware).
routes[].speedSourcestringOne of: live, typical, estimated.
routes[].summarystring
routes[].geometryLineStringRequired.
routes[].geometry.typestringRequired.
routes[].geometry.coordinatesnumber[][]Required.
routes[].legsLeg[]Required. One per part between stops.
routes[].legs[].distanceMnumberRequired.
routes[].legs[].durationSnumberRequired.
routes[].stepsStep[]Required.
routes[].steps[].maneuverstringRequired. depart, arrive, continue, left, right, slight_left, sharp_right, uturn_left, roundabout_enter, ferry_enter, … (other)
routes[].steps[].instructionstringRequired.
routes[].steps[].distanceMnumberRequired.
routes[].steps[].durationSnumberRequired.
routes[].steps[].streetNamesstring[]
routes[].steps[].startIndexintegerRequired. Index into geometry.coordinates
routes[].steps[].endIndexintegerRequired.
routes[].steps[].roundaboutExitinteger
routes[].steps[].towardstring[]
routes[].steps[].atTrafficLightboolean
routes[].steps[].crossingstringOn foot: footbridge, underpass, zebra, signals, crossing, junction
routes[].segmentsobject[]Trips that change how you travel (train, boat, okada with a walk past a ban).
routes[].segments[].modestringRequired. One of: walk, okada, drive, train, boat.
routes[].segments[].linestring
routes[].segments[].fromstringRequired.
routes[].segments[].tostringRequired.
routes[].segments[].distanceMnumberRequired.
routes[].segments[].durationSnumberRequired.
routes[].segments[].waitSnumber
routes[].segments[].stopsinteger
routes[].segments[].scheduledboolean
routes[].segments[].estimatedboolean
routes[].segments[].farestring
routes[].segments[].notestring
routes[].segments[].geometryLineStringRequired.
routes[].segments[].geometry.typestringRequired.
routes[].segments[].geometry.coordinatesnumber[][]Required.
routes[].congestionobject[]
routes[].congestion[].startIndexinteger
routes[].congestion[].endIndexinteger
routes[].congestion[].levelstring
routes[].tollsobject
routes[].tolls.gatesobject[]
routes[].tolls.gates[].namestring
routes[].tolls.gates[].locationPoint
routes[].tolls.gates[].atMinteger
routes[].tolls.gates[].priceinteger | null
routes[].tolls.gates[].currencystring
routes[].tolls.gates[].paymentstring
routes[].tolls.totalobject
routes[].tolls.unknownPricesinteger
routes[].borderCrossingsobject[]
routes[].borderCrossings[].fromstring
routes[].borderCrossings[].tostring
routes[].borderCrossings[].locationPoint
routes[].borderCrossings[].location.typestringRequired.
routes[].borderCrossings[].location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
routes[].borderCrossings[].atMinteger
routes[].borderCrossings[].poststring
routes[].borderCrossings[].clockChangeHnumber
routes[].vehicleRulesobjectokada, keke and danfo trips
routes[].vehicleRules.vehiclestringOne of: okada, motorbike, keke, danfo.
routes[].vehicleRules.avoidedBan[]
routes[].vehicleRules.avoided[].idstringRequired.
routes[].vehicleRules.avoided[].zonestringRequired.
routes[].vehicleRules.avoided[].scopestringRequired.
routes[].vehicleRules.avoided[].hoursstring
routes[].vehicleRules.avoided[].sincestring
routes[].vehicleRules.avoided[].sourcestring (uri)
routes[].vehicleRules.avoided[].wherestringOne of: origin, destination, stop, route.
routes[].vehicleRules.avoided[].walkMnumber
routes[].vehicleRules.adviceBan[]
routes[].vehicleRules.advice[].idstringRequired.
routes[].vehicleRules.advice[].zonestringRequired.
routes[].vehicleRules.advice[].scopestringRequired.
routes[].vehicleRules.advice[].hoursstring
routes[].vehicleRules.advice[].sincestring
routes[].vehicleRules.advice[].sourcestring (uri)
routes[].vehicleRules.advice[].wherestringOne of: origin, destination, stop, route.
routes[].vehicleRules.advice[].walkMnumber
routes[].vehicleRules.endBanBan
routes[].vehicleRules.endBan.idstringRequired.
routes[].vehicleRules.endBan.zonestringRequired.
routes[].vehicleRules.endBan.scopestringRequired.
routes[].vehicleRules.endBan.hoursstring
routes[].vehicleRules.endBan.sincestring
routes[].vehicleRules.endBan.sourcestring (uri)
routes[].vehicleRules.endBan.wherestringOne of: origin, destination, stop, route.
routes[].vehicleRules.endBan.walkMnumber
routes[].vehicleRules.allowedByRequestBan[]
routes[].vehicleRules.allowedByRequest[].idstringRequired.
routes[].vehicleRules.allowedByRequest[].zonestringRequired.
routes[].vehicleRules.allowedByRequest[].scopestringRequired.
routes[].vehicleRules.allowedByRequest[].hoursstring
routes[].vehicleRules.allowedByRequest[].sincestring
routes[].vehicleRules.allowedByRequest[].sourcestring (uri)
routes[].vehicleRules.allowedByRequest[].wherestringOne of: origin, destination, stop, route.
routes[].vehicleRules.allowedByRequest[].walkMnumber
routes[].vehicleRules.reportedobject[]
routes[].vehicleRules.reported[].locationPoint
routes[].vehicleRules.reported[].reportersinteger
routes[].vehicleRules.reported[].lastSeenstring
routes[].lastMileobject
routes[].lastMile.stopAtPoint
routes[].lastMile.stopAt.typestringRequired.
routes[].lastMile.stopAt.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
routes[].lastMile.stopNamestring
routes[].lastMile.modestring
routes[].lastMile.distanceMnumber
routes[].lastMile.durationSnumber
routes[].lastMile.geometryLineString
routes[].lastMile.geometry.typestringRequired.
routes[].lastMile.geometry.coordinatesnumber[][]Required.
routes[].accessobject
routes[].access.kindstringOne of: estate, government, military, police, gate.
routes[].access.textstring
routes[].access.namestring
routes[].access.gatePoint
routes[].access.gate.typestringRequired.
routes[].access.gate.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
routes[].access.dropOffAtGateboolean
routes[].roadConditionobject
routes[].roadCondition.roughMnumber
routes[].countrystring
routes[].warningsstring[]
routes[].faresFareEstimate[]
routes[].fares[].modestringRequired. One of: taxi, shared_taxi, okada, keke, bus, ridehail, boat.
routes[].fares[].servicestring
routes[].fares[].currencystringRequired. One of: NGN, GHS, XOF.
routes[].fares[].lowintegerRequired.
routes[].fares[].typicalintegerRequired.
routes[].fares[].highintegerRequired.
routes[].fares[].textstringRequired.
routes[].fares[].perPersonbooleanRequired.
routes[].fares[].charterbooleanRequired.
routes[].fares[].nightboolean
routes[].fares[].rushboolean
routes[].fares[].rainboolean
routes[].fares[].basisstringRequired. One of: crowd, guide.
routes[].fares[].reportsintegerRequired.
routes[].fares[].durationSnumberRequired.
routes[].fares[].openingOfferintegerWhere prices are haggled: a good first offer.
routes[].fares[].sourcesstring (uri)[]
waypointsobject[]Required. Where each waypoint was routed to, in order.
waypoints[].locationPointRequired.
waypoints[].location.typestringRequired.
waypoints[].location.coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
waypoints[].postcodestring
waypoints[].entrancestring
modestringRequired. One of: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle, boat, train. Default: drive.
warningsstring[]
unconfirmedBansBan[]
unconfirmedBans[].idstringRequired.
unconfirmedBans[].zonestringRequired.
unconfirmedBans[].scopestringRequired.
unconfirmedBans[].hoursstring
unconfirmedBans[].sincestring
unconfirmedBans[].sourcestring (uri)
unconfirmedBans[].wherestringOne of: origin, destination, stop, route.
unconfirmedBans[].walkMnumber
attributionstringRequired.
200 OK
{
  "routes": [
    {
      "distanceM": 0,
      "durationS": 0,
      "staticDurationS": 0,
      "trafficDelayS": 0,
      "speedSource": "live",
      "summary": "Admiralty Way and Awudu Ekpekha Boulevard",
      "geometry": {
        "type": "string",
        "coordinates": [
          []
        ]
      },
      "legs": [
        {
          "distanceM": 0,
          "durationS": 0
        }
      ],
      "steps": [
        {
          "maneuver": "right",
          "instruction": "Turn right onto Admiralty Way.",
          "distanceM": 0,
          "durationS": 0,
          "streetNames": [],
          "startIndex": 0,
          "endIndex": 0,
          "roundaboutExit": 0,
          "toward": [],
          "atTrafficLight": true,
          "crossing": "string"
        }
      ],
      "segments": [
        {
          "mode": "walk",
          "line": "string",
          "from": "string",
          "to": "string",
          "distanceM": 0,
          "durationS": 0,
          "waitS": 0,
          "stops": 0,
          "scheduled": true,
          "estimated": true,
          "fare": "string",
          "note": "string",
          "geometry": {}
        }
      ],
      "congestion": [
        {
          "startIndex": 0,
          "endIndex": 0,
          "level": "string"
        }
      ],
      "tolls": {
        "gates": [
          {}
        ],
        "total": {
          "NGN": 300
        },
        "unknownPrices": 0
      },
      "borderCrossings": [
        {
          "from": "string",
          "to": "string",
          "location": {},
          "atM": 0,
          "post": "string",
          "clockChangeH": 0
        }
      ],
      "vehicleRules": {
        "vehicle": "okada",
        "avoided": [
          {}
        ],
        "advice": [
          {}
        ],
        "endBan": {
          "id": "string",
          "zone": "Third Mainland Bridge",
          "scope": "string",
          "hours": "string",
          "since": "string",
          "source": "string",
          "where": "origin",
          "walkM": 0
        },
        "allowedByRequest": [
          {}
        ],
        "reported": [
          {}
        ]
      },
      "lastMile": {
        "stopAt": {
          "type": "string",
          "coordinates": []
        },
        "stopName": "string",
        "mode": "string",
        "distanceM": 0,
        "durationS": 0,
        "geometry": {
          "type": "string",
          "coordinates": []
        }
      },
      "access": {
        "kind": "estate",
        "text": "string",
        "name": "string",
        "gate": {
          "type": "string",
          "coordinates": []
        },
        "dropOffAtGate": true
      },
      "roadCondition": {
        "roughM": 0
      },
      "country": "string",
      "warnings": [
        "string"
      ],
      "fares": [
        {
          "mode": "taxi",
          "service": "Bolt",
          "currency": "NGN",
          "low": 0,
          "typical": 0,
          "high": 0,
          "text": "₦3,000–4,500",
          "perPerson": true,
          "charter": true,
          "night": true,
          "rush": true,
          "rain": true,
          "basis": "crowd",
          "reports": 0,
          "durationS": 0,
          "openingOffer": 0,
          "sources": []
        }
      ]
    }
  ],
  "waypoints": [
    {
      "location": {
        "type": "string",
        "coordinates": [
          0
        ]
      },
      "postcode": "string",
      "entrance": "string"
    }
  ],
  "mode": "drive",
  "warnings": [
    "string"
  ],
  "unconfirmedBans": [
    {
      "id": "string",
      "zone": "Third Mainland Bridge",
      "scope": "string",
      "hours": "string",
      "since": "string",
      "source": "string",
      "where": "origin",
      "walkM": 0
    }
  ],
  "attribution": "string"
}

Errors

  • default Error

Travel times from many origins to many destinations (per element)

POST https://nways.ng/maps/v1/routes/matrix

Up to 50 origins and 50 destinations, 625 elements (origins × destinations), each billed as one route_matrix unit. Modes drive, van, walk, bicycle; okada, keke and danfo keep to their bans as /routes/compute does (an element from or to a ban area is NOT_ALLOWED, with the ban); motorbike and dispatch to bans on every motorcycle only. Points at most 400 km apart by car, 200 km otherwise. Reasons: MODE_INVALID, MATRIX_TOO_LARGE, MATRIX_TOO_FAR, WAYPOINT_INVALID, POSTCODE_INVALID, POSTCODE_NOT_FOUND, GHANAPOST_INVALID, GHANAPOST_NOT_FOUND, PLUSCODE_INVALID, ROUTING_UNAVAILABLE (503).

Parameters

NameInTypeDescription
fieldsquerystringComma list of the fields to keep in each result (a.b reaches into objects; id is always kept; * = all).

Request body

FieldTypeDescription
originsWaypoint[]Required. At least 1 items, at most 50 items.
origins[].latnumber
origins[].lngnumber
origins[].postcodestring
origins[].ghanaPoststring
origins[].plusCodestring
origins[].headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
destinationsWaypoint[]Required. At least 1 items, at most 50 items.
destinations[].latnumber
destinations[].lngnumber
destinations[].postcodestring
destinations[].ghanaPoststring
destinations[].plusCodestring
destinations[].headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
modestringokada, keke and danfo keep to their bans (as /routes/compute); motorbike and dispatch (couriers' bikes) only to bans on every motorcycle. One of: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle. Default: drive.
allowBansstring[]
cURL
curl -X POST "https://nways.ng/maps/v1/routes/matrix" \
  -H "X-NWays-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origins":[{"lat":6.4474,"lng":3.472},{"postcode":"LA08A09DB09"}],"destinations":[{"lat":6.43,"lng":3.42},{"lat":6.45,"lng":3.4}],"mode":"motorbike"}'
JavaScript
const res = await fetch('https://nways.ng/maps/v1/routes/matrix', {
  method: 'POST',
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "origins": [
      {
        "lat": 6.4474,
        "lng": 3.472
      },
      {
        "postcode": "LA08A09DB09"
      }
    ],
    "destinations": [
      {
        "lat": 6.43,
        "lng": 3.42
      },
      {
        "lat": 6.45,
        "lng": 3.4
      }
    ],
    "mode": "motorbike"
  }),
})
const data = await res.json()
Python
import os
import requests

res = requests.post(
    "https://nways.ng/maps/v1/routes/matrix",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    json={"origins": [{"lat": 6.4474, "lng": 3.472}, {"postcode": "LA08A09DB09"}], "destinations": [{"lat": 6.43, "lng": 3.42}, {"lat": 6.45, "lng": 3.4}], "mode": "motorbike"},
    timeout=10,
)
data = res.json()

Response

The matrix

FieldTypeDescription
elementsobject[]Required.
elements[].originIndexintegerRequired.
elements[].destinationIndexintegerRequired.
elements[].statusstringRequired. NOT_ALLOWED: the origin or destination is inside a ban area for the mode (ban says which). One of: OK, ROUTE_NOT_FOUND, NOT_ALLOWED.
elements[].durationSnumberRequired.
elements[].distanceMnumberRequired.
elements[].banBan
elements[].ban.idstringRequired.
elements[].ban.zonestringRequired.
elements[].ban.scopestringRequired.
elements[].ban.hoursstring
elements[].ban.sincestring
elements[].ban.sourcestring (uri)
elements[].ban.wherestringOne of: origin, destination, stop, route.
elements[].ban.walkMnumber
originsPoint[]Required.
origins[].typestringRequired.
origins[].coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
destinationsPoint[]Required.
destinations[].typestringRequired.
destinations[].coordinatesnumber[]Required. [lng, lat] At least 2 items, at most 2 items.
modestringRequired.
attributionstringRequired.
200 OK
{
  "elements": [
    {
      "originIndex": 0,
      "destinationIndex": 0,
      "status": "OK",
      "durationS": 0,
      "distanceM": 0,
      "ban": {
        "id": "string",
        "zone": "Third Mainland Bridge",
        "scope": "string",
        "hours": "string",
        "since": "string",
        "source": "string",
        "where": "origin",
        "walkM": 0
      }
    }
  ],
  "origins": [
    {
      "type": "string",
      "coordinates": [
        0
      ]
    }
  ],
  "destinations": [
    {
      "type": "string",
      "coordinates": [
        0
      ]
    }
  ],
  "mode": "string",
  "attribution": "string"
}

Errors

  • default Error

Which vehicle visits which stops, in what order

POST https://nways.ng/maps/v1/routes/optimize

Modes as /routes/matrix: stops inside a ban area for the mode are unassigned and listed in notAllowed. Up to 50 stops and 5 vehicles (start, optional end, capacity): the least total time within each vehicle's capacity, by a fast heuristic on the engine's travel times (not a guaranteed optimum). Each vehicle's route is planned like /routes/compute unless geometry is false. One route_optimization call. Reasons: MODE_INVALID, STOPS_INVALID, VEHICLES_INVALID, STOP_ID_INVALID, VEHICLE_ID_INVALID, STOP_INVALID, CAPACITY_INVALID, STOPS_TOO_FAR, WAYPOINT_INVALID, POSTCODE_INVALID, POSTCODE_NOT_FOUND, GHANAPOST_INVALID, GHANAPOST_NOT_FOUND, PLUSCODE_INVALID, LANG_INVALID, ROUTING_UNAVAILABLE (503).

Request body

FieldTypeDescription
stopsobject[]Required. At least 1 items, at most 50 items.
stops[].idstringRequired.
stops[].locationWaypointRequired. Exactly one of lat and lng, postcode (NIPOST: routes to its best entrance), ghanaPost, or plusCode (full, or short with a town after it).
stops[].location.latnumber
stops[].location.lngnumber
stops[].location.postcodestring
stops[].location.ghanaPoststring
stops[].location.plusCodestring
stops[].location.headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
stops[].demandintegerDefault: 1. ≥ 1.
stops[].serviceSnumberDefault: 0. ≥ 0, ≤ 14400.
vehiclesobject[]Required. At least 1 items, at most 5 items.
vehicles[].idstringRequired.
vehicles[].startWaypointRequired. Exactly one of lat and lng, postcode (NIPOST: routes to its best entrance), ghanaPost, or plusCode (full, or short with a town after it).
vehicles[].start.latnumber
vehicles[].start.lngnumber
vehicles[].start.postcodestring
vehicles[].start.ghanaPoststring
vehicles[].start.plusCodestring
vehicles[].start.headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
vehicles[].endWaypointExactly one of lat and lng, postcode (NIPOST: routes to its best entrance), ghanaPost, or plusCode (full, or short with a town after it).
vehicles[].end.latnumber
vehicles[].end.lngnumber
vehicles[].end.postcodestring
vehicles[].end.ghanaPoststring
vehicles[].end.plusCodestring
vehicles[].end.headingnumberOrigin only: direction of travel (degrees), so a moving vehicle doesn't start with a U-turn.
vehicles[].capacityinteger0 = no limit Default: 0. ≥ 0.
modestringokada, keke and danfo keep to their bans (as /routes/compute); motorbike and dispatch (couriers' bikes) only to bans on every motorcycle. One of: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle. Default: drive.
allowBansstring[]
geometrybooleanDefault: true.
langstringOne of: en, fr, pt.
cURL
curl -X POST "https://nways.ng/maps/v1/routes/optimize" \
  -H "X-NWays-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"stops":[{"id":"order-1","location":{"lat":6.44,"lng":3.4},"serviceS":120},{"id":"order-2","location":{"postcode":"LA08A09DB09"},"demand":2}],"vehicles":[{"id":"bike-1","start":{"lat":6.4474,"lng":3.472},"capacity":6}],"mode":"motorbike"}'
JavaScript
const res = await fetch('https://nways.ng/maps/v1/routes/optimize', {
  method: 'POST',
  headers: { 'X-NWays-Api-Key': process.env.NWAYS_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "stops": [
      {
        "id": "order-1",
        "location": {
          "lat": 6.44,
          "lng": 3.4
        },
        "serviceS": 120
      },
      {
        "id": "order-2",
        "location": {
          "postcode": "LA08A09DB09"
        },
        "demand": 2
      }
    ],
    "vehicles": [
      {
        "id": "bike-1",
        "start": {
          "lat": 6.4474,
          "lng": 3.472
        },
        "capacity": 6
      }
    ],
    "mode": "motorbike"
  }),
})
const data = await res.json()
Python
import os
import requests

res = requests.post(
    "https://nways.ng/maps/v1/routes/optimize",
    headers={"X-NWays-Api-Key": os.environ["NWAYS_API_KEY"]},
    json={"stops": [{"id": "order-1", "location": {"lat": 6.44, "lng": 3.4}, "serviceS": 120}, {"id": "order-2", "location": {"postcode": "LA08A09DB09"}, "demand": 2}], "vehicles": [{"id": "bike-1", "start": {"lat": 6.4474, "lng": 3.472}, "capacity": 6}], "mode": "motorbike"},
    timeout=10,
)
data = res.json()

Response

The plan

FieldTypeDescription
routesobject[]Required.
routes[].vehiclestringRequired.
routes[].stopsstring[]Required. Stop ids in visiting order
routes[].durationSnumberRequired.
routes[].distanceMnumberRequired.
routes[].serviceSnumberRequired.
routes[].loadintegerRequired.
routes[].arrivalsSnumber[]Required. Seconds from the start to each stop
routes[].routeRoute
routes[].route.distanceMnumberRequired.
routes[].route.durationSnumberRequired.
routes[].route.staticDurationSnumberRequired. Without live traffic
routes[].route.trafficDelaySnumberRequired. What traffic and incidents add now (traffic_aware).
routes[].route.speedSourcestringOne of: live, typical, estimated.
routes[].route.summarystring
routes[].route.geometryLineStringRequired.
routes[].route.geometry.typestringRequired.
routes[].route.geometry.coordinatesnumber[][]Required.
routes[].route.legsLeg[]Required. One per part between stops.
routes[].route.legs[].distanceMnumberRequired.
routes[].route.legs[].durationSnumberRequired.
routes[].route.stepsStep[]Required.
routes[].route.steps[].maneuverstringRequired. depart, arrive, continue, left, right, slight_left, sharp_right, uturn_left, roundabout_enter, ferry_enter, … (other)
routes[].route.steps[].instructionstringRequired.
routes[].route.steps[].distanceMnumberRequired.
routes[].route.steps[].durationSnumberRequired.
routes[].route.steps[].streetNamesstring[]
routes[].route.steps[].startIndexintegerRequired. Index into geometry.coordinates
routes[].route.steps[].endIndexintegerRequired.
routes[].route.steps[].roundaboutExitinteger
routes[].route.steps[].towardstring[]
routes[].route.steps[].atTrafficLightboolean
routes[].route.steps[].crossingstringOn foot: footbridge, underpass, zebra, signals, crossing, junction
routes[].route.segmentsobject[]Trips that change how you travel (train, boat, okada with a walk past a ban).
routes[].route.segments[].modestringRequired. One of: walk, okada, drive, train, boat.
routes[].route.segments[].linestring
routes[].route.segments[].fromstringRequired.
routes[].route.segments[].tostringRequired.
routes[].route.segments[].distanceMnumberRequired.
routes[].route.segments[].durationSnumberRequired.
routes[].route.segments[].waitSnumber
routes[].route.segments[].stopsinteger
routes[].route.segments[].scheduledboolean
routes[].route.segments[].estimatedboolean
routes[].route.segments[].farestring
routes[].route.segments[].notestring
routes[].route.segments[].geometryLineStringRequired.
routes[].route.congestionobject[]
routes[].route.congestion[].startIndexinteger
routes[].route.congestion[].endIndexinteger
routes[].route.congestion[].levelstring
routes[].route.tollsobject
routes[].route.tolls.gatesobject[]
routes[].route.tolls.totalobject
routes[].route.tolls.unknownPricesinteger
routes[].route.borderCrossingsobject[]
routes[].route.borderCrossings[].fromstring
routes[].route.borderCrossings[].tostring
routes[].route.borderCrossings[].locationPoint
routes[].route.borderCrossings[].atMinteger
routes[].route.borderCrossings[].poststring
routes[].route.borderCrossings[].clockChangeHnumber
routes[].route.vehicleRulesobjectokada, keke and danfo trips
routes[].route.vehicleRules.vehiclestringOne of: okada, motorbike, keke, danfo.
routes[].route.vehicleRules.avoidedBan[]
routes[].route.vehicleRules.adviceBan[]
routes[].route.vehicleRules.endBanBan
routes[].route.vehicleRules.allowedByRequestBan[]
routes[].route.vehicleRules.reportedobject[]
routes[].route.lastMileobject
routes[].route.lastMile.stopAtPoint
routes[].route.lastMile.stopNamestring
routes[].route.lastMile.modestring
routes[].route.lastMile.distanceMnumber
routes[].route.lastMile.durationSnumber
routes[].route.lastMile.geometryLineString
routes[].route.accessobject
routes[].route.access.kindstringOne of: estate, government, military, police, gate.
routes[].route.access.textstring
routes[].route.access.namestring
routes[].route.access.gatePoint
routes[].route.access.dropOffAtGateboolean
routes[].route.roadConditionobject
routes[].route.roadCondition.roughMnumber
routes[].route.countrystring
routes[].route.warningsstring[]
routes[].route.faresFareEstimate[]
routes[].route.fares[].modestringRequired. One of: taxi, shared_taxi, okada, keke, bus, ridehail, boat.
routes[].route.fares[].servicestring
routes[].route.fares[].currencystringRequired. One of: NGN, GHS, XOF.
routes[].route.fares[].lowintegerRequired.
routes[].route.fares[].typicalintegerRequired.
routes[].route.fares[].highintegerRequired.
routes[].route.fares[].textstringRequired.
routes[].route.fares[].perPersonbooleanRequired.
routes[].route.fares[].charterbooleanRequired.
routes[].route.fares[].nightboolean
routes[].route.fares[].rushboolean
routes[].route.fares[].rainboolean
routes[].route.fares[].basisstringRequired. One of: crowd, guide.
routes[].route.fares[].reportsintegerRequired.
routes[].route.fares[].durationSnumberRequired.
routes[].route.fares[].openingOfferintegerWhere prices are haggled: a good first offer.
routes[].route.fares[].sourcesstring (uri)[]
unassignedstring[]Required.
notAllowedobject[]Stops, or vehicles' starts and ends, inside a ban area for the mode.
notAllowed[].stopstring
notAllowed[].vehiclestring
notAllowed[].banBanRequired.
notAllowed[].ban.idstringRequired.
notAllowed[].ban.zonestringRequired.
notAllowed[].ban.scopestringRequired.
notAllowed[].ban.hoursstring
notAllowed[].ban.sincestring
notAllowed[].ban.sourcestring (uri)
notAllowed[].ban.wherestringOne of: origin, destination, stop, route.
notAllowed[].ban.walkMnumber
durationSnumberRequired.
modestringRequired.
attributionstringRequired.
200 OK
{
  "routes": [
    {
      "vehicle": "string",
      "stops": [
        "string"
      ],
      "durationS": 0,
      "distanceM": 0,
      "serviceS": 0,
      "load": 0,
      "arrivalsS": [
        0
      ],
      "route": {
        "distanceM": 0,
        "durationS": 0,
        "staticDurationS": 0,
        "trafficDelayS": 0,
        "speedSource": "live",
        "summary": "Admiralty Way and Awudu Ekpekha Boulevard",
        "geometry": {
          "type": "string",
          "coordinates": []
        },
        "legs": [
          {}
        ],
        "steps": [
          {}
        ],
        "segments": [
          {}
        ],
        "congestion": [
          {}
        ],
        "tolls": {
          "gates": [],
          "total": {
            "NGN": 300
          },
          "unknownPrices": 0
        },
        "borderCrossings": [
          {}
        ],
        "vehicleRules": {
          "vehicle": "okada",
          "avoided": [],
          "advice": [],
          "endBan": {},
          "allowedByRequest": [],
          "reported": []
        },
        "lastMile": {
          "stopAt": {},
          "stopName": "string",
          "mode": "string",
          "distanceM": 0,
          "durationS": 0,
          "geometry": {}
        },
        "access": {
          "kind": "estate",
          "text": "string",
          "name": "string",
          "gate": {},
          "dropOffAtGate": true
        },
        "roadCondition": {
          "roughM": 0
        },
        "country": "string",
        "warnings": [
          "string"
        ],
        "fares": [
          {}
        ]
      }
    }
  ],
  "unassigned": [
    "string"
  ],
  "notAllowed": [
    {
      "stop": "string",
      "vehicle": "string",
      "ban": {
        "id": "string",
        "zone": "Third Mainland Bridge",
        "scope": "string",
        "hours": "string",
        "since": "string",
        "source": "string",
        "where": "origin",
        "walkM": 0
      }
    }
  ],
  "durationS": 0,
  "mode": "string",
  "attribution": "string"
}

Errors

  • default Error