Itinéraires
Des itinéraires pour chaque façon de se déplacer, la matrice d’itinéraires et l’optimisation de tournées.
Sur cette page
Envoyez votre clé avec key=VOTRE_CLE_API dans l’adresse, ou dans l’en-tête X-NWays-Api-Key. Clés d’API
Adresse de base : https://nways.ng/maps/v1
Un itinéraire, avec jusqu’à 25 arrêts intermédiaires
POST https://nways.ng/maps/v1/routes/compute
Voiture, fourgonnette, okada (moto-taxi ; respecte les interdictions d’okada et fait marcher au-delà de la limite d’une zone interdite), moto (la vôtre) et dispatch (motos de coursiers : exemptées des interdictions d’okada à passagers), keke et danfo (respectent leurs interdictions), marche, vélo, bateau (bateaux de passagers et embarcadères) et train. Pour un code postal, l’itinéraire mène à la meilleure entrée du bâtiment ; là où la route s’arrête avant la porte, l’itinéraire indique où s’arrêter et comment finir (lastMile) ; péages dans leurs devises, passages de frontière, résidences fermées, interdictions évitées avec leurs sources. fields= choisit les champs de chaque itinéraire. Motifs : 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).
Paramètres
| Nom | Où | Type | Description |
|---|---|---|---|
fields | requête | string | Liste séparée par des virgules des champs à garder dans chaque résultat (a.b descend dans les objets ; id est toujours gardé ; * = tous). |
Corps de la requête
| Champ | Type | Description |
|---|---|---|
origin | Waypoint | Obligatoire. Exactement un élément parmi lat et lng, postcode (NIPOST : l’itinéraire mène à sa meilleure entrée), ghanaPost ou plusCode (complet, ou court suivi d’une ville). |
origin.lat | number | |
origin.lng | number | |
origin.postcode | string | |
origin.ghanaPost | string | |
origin.plusCode | string | |
origin.heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
destination | Waypoint | Obligatoire. Exactement un élément parmi lat et lng, postcode (NIPOST : l’itinéraire mène à sa meilleure entrée), ghanaPost ou plusCode (complet, ou court suivi d’une ville). |
destination.lat | number | |
destination.lng | number | |
destination.postcode | string | |
destination.ghanaPost | string | |
destination.plusCode | string | |
destination.heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
intermediates | Waypoint[] | Au plus 25 éléments. |
intermediates[].lat | number | |
intermediates[].lng | number | |
intermediates[].postcode | string | |
intermediates[].ghanaPost | string | |
intermediates[].plusCode | string | |
intermediates[].heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
mode | string | Au choix: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle, boat, train. Par défaut: drive. |
alternatives | boolean | Jusqu’à 2 itinéraires de plus (sans arrêts intermédiaires). Par défaut: false. |
routingPreference | string | Au choix: traffic_unaware, traffic_aware. Par défaut: traffic_unaware. |
departAt | string (date-time) | |
avoid | string[] | |
lang | string | Au choix: en, fr, pt. |
tollVehicle | string | Classe de tarif de péage (van : bus). Au choix: car, suv, bus, truck. |
access | string | Trajets en train et en bateau : vers et depuis les gares et les embarcadères. Au choix: walk, okada, drive. |
lastMile | string | Au choix: walk, okada. |
allowBans | string[] | Ids d’interdictions non confirmées (tirés de unconfirmedBans) à traverser quand même. |
fares | boolean | Ajouter des estimations de tarif à chaque itinéraire (SKU avancé). Par défaut: false. |
curl -X POST "https://nways.ng/maps/v1/routes/compute" \
-H "X-NWays-Api-Key: VOTRE_CLE_API" \
-H "Content-Type: application/json" \
-d '{"origin":{"lat":6.4474,"lng":3.472},"destination":{"postcode":"LA08A09DB10"},"mode":"drive","routingPreference":"traffic_aware"}'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()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()Réponse
Itinéraires
| Champ | Type | Description |
|---|---|---|
routes | Route[] | Obligatoire. |
routes[].distanceM | number | Obligatoire. |
routes[].durationS | number | Obligatoire. |
routes[].staticDurationS | number | Obligatoire. Sans le trafic en direct |
routes[].trafficDelayS | number | Obligatoire. Ce que le trafic et les incidents ajoutent en ce moment (traffic_aware). |
routes[].speedSource | string | Au choix: live, typical, estimated. |
routes[].summary | string | |
routes[].geometry | LineString | Obligatoire. |
routes[].geometry.type | string | Obligatoire. |
routes[].geometry.coordinates | number[][] | Obligatoire. |
routes[].legs | Leg[] | Obligatoire. Un par tronçon entre deux arrêts. |
routes[].legs[].distanceM | number | Obligatoire. |
routes[].legs[].durationS | number | Obligatoire. |
routes[].steps | Step[] | Obligatoire. |
routes[].steps[].maneuver | string | Obligatoire. depart, arrive, continue, left, right, slight_left, sharp_right, uturn_left, roundabout_enter, ferry_enter, … (autre) |
routes[].steps[].instruction | string | Obligatoire. |
routes[].steps[].distanceM | number | Obligatoire. |
routes[].steps[].durationS | number | Obligatoire. |
routes[].steps[].streetNames | string[] | |
routes[].steps[].startIndex | integer | Obligatoire. Index dans geometry.coordinates |
routes[].steps[].endIndex | integer | Obligatoire. |
routes[].steps[].roundaboutExit | integer | |
routes[].steps[].toward | string[] | |
routes[].steps[].atTrafficLight | boolean | |
routes[].steps[].crossing | string | À pied : footbridge, underpass, zebra, signals, crossing, junction |
routes[].segments | object[] | Trajets qui changent de mode de déplacement (train, bateau, okada avec une marche au-delà d’une interdiction). |
routes[].segments[].mode | string | Obligatoire. Au choix: walk, okada, drive, train, boat. |
routes[].segments[].line | string | |
routes[].segments[].from | string | Obligatoire. |
routes[].segments[].to | string | Obligatoire. |
routes[].segments[].distanceM | number | Obligatoire. |
routes[].segments[].durationS | number | Obligatoire. |
routes[].segments[].waitS | number | |
routes[].segments[].stops | integer | |
routes[].segments[].scheduled | boolean | |
routes[].segments[].estimated | boolean | |
routes[].segments[].fare | string | |
routes[].segments[].note | string | |
routes[].segments[].geometry | LineString | Obligatoire. |
routes[].segments[].geometry.type | string | Obligatoire. |
routes[].segments[].geometry.coordinates | number[][] | Obligatoire. |
routes[].congestion | object[] | |
routes[].congestion[].startIndex | integer | |
routes[].congestion[].endIndex | integer | |
routes[].congestion[].level | string | |
routes[].tolls | object | |
routes[].tolls.gates | object[] | |
routes[].tolls.gates[].name | string | |
routes[].tolls.gates[].location | Point | |
routes[].tolls.gates[].atM | integer | |
routes[].tolls.gates[].price | integer | null | |
routes[].tolls.gates[].currency | string | |
routes[].tolls.gates[].payment | string | |
routes[].tolls.total | object | |
routes[].tolls.unknownPrices | integer | |
routes[].borderCrossings | object[] | |
routes[].borderCrossings[].from | string | |
routes[].borderCrossings[].to | string | |
routes[].borderCrossings[].location | Point | |
routes[].borderCrossings[].location.type | string | Obligatoire. |
routes[].borderCrossings[].location.coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
routes[].borderCrossings[].atM | integer | |
routes[].borderCrossings[].post | string | |
routes[].borderCrossings[].clockChangeH | number | |
routes[].vehicleRules | object | Trajets en okada, keke et danfo |
routes[].vehicleRules.vehicle | string | Au choix: okada, motorbike, keke, danfo. |
routes[].vehicleRules.avoided | Ban[] | |
routes[].vehicleRules.avoided[].id | string | Obligatoire. |
routes[].vehicleRules.avoided[].zone | string | Obligatoire. |
routes[].vehicleRules.avoided[].scope | string | Obligatoire. |
routes[].vehicleRules.avoided[].hours | string | |
routes[].vehicleRules.avoided[].since | string | |
routes[].vehicleRules.avoided[].source | string (uri) | |
routes[].vehicleRules.avoided[].where | string | Au choix: origin, destination, stop, route. |
routes[].vehicleRules.avoided[].walkM | number | |
routes[].vehicleRules.advice | Ban[] | |
routes[].vehicleRules.advice[].id | string | Obligatoire. |
routes[].vehicleRules.advice[].zone | string | Obligatoire. |
routes[].vehicleRules.advice[].scope | string | Obligatoire. |
routes[].vehicleRules.advice[].hours | string | |
routes[].vehicleRules.advice[].since | string | |
routes[].vehicleRules.advice[].source | string (uri) | |
routes[].vehicleRules.advice[].where | string | Au choix: origin, destination, stop, route. |
routes[].vehicleRules.advice[].walkM | number | |
routes[].vehicleRules.endBan | Ban | |
routes[].vehicleRules.endBan.id | string | Obligatoire. |
routes[].vehicleRules.endBan.zone | string | Obligatoire. |
routes[].vehicleRules.endBan.scope | string | Obligatoire. |
routes[].vehicleRules.endBan.hours | string | |
routes[].vehicleRules.endBan.since | string | |
routes[].vehicleRules.endBan.source | string (uri) | |
routes[].vehicleRules.endBan.where | string | Au choix: origin, destination, stop, route. |
routes[].vehicleRules.endBan.walkM | number | |
routes[].vehicleRules.allowedByRequest | Ban[] | |
routes[].vehicleRules.allowedByRequest[].id | string | Obligatoire. |
routes[].vehicleRules.allowedByRequest[].zone | string | Obligatoire. |
routes[].vehicleRules.allowedByRequest[].scope | string | Obligatoire. |
routes[].vehicleRules.allowedByRequest[].hours | string | |
routes[].vehicleRules.allowedByRequest[].since | string | |
routes[].vehicleRules.allowedByRequest[].source | string (uri) | |
routes[].vehicleRules.allowedByRequest[].where | string | Au choix: origin, destination, stop, route. |
routes[].vehicleRules.allowedByRequest[].walkM | number | |
routes[].vehicleRules.reported | object[] | |
routes[].vehicleRules.reported[].location | Point | |
routes[].vehicleRules.reported[].reporters | integer | |
routes[].vehicleRules.reported[].lastSeen | string | |
routes[].lastMile | object | |
routes[].lastMile.stopAt | Point | |
routes[].lastMile.stopAt.type | string | Obligatoire. |
routes[].lastMile.stopAt.coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
routes[].lastMile.stopName | string | |
routes[].lastMile.mode | string | |
routes[].lastMile.distanceM | number | |
routes[].lastMile.durationS | number | |
routes[].lastMile.geometry | LineString | |
routes[].lastMile.geometry.type | string | Obligatoire. |
routes[].lastMile.geometry.coordinates | number[][] | Obligatoire. |
routes[].access | object | |
routes[].access.kind | string | Au choix: estate, government, military, police, gate. |
routes[].access.text | string | |
routes[].access.name | string | |
routes[].access.gate | Point | |
routes[].access.gate.type | string | Obligatoire. |
routes[].access.gate.coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
routes[].access.dropOffAtGate | boolean | |
routes[].roadCondition | object | |
routes[].roadCondition.roughM | number | |
routes[].country | string | |
routes[].warnings | string[] | |
routes[].fares | FareEstimate[] | |
routes[].fares[].mode | string | Obligatoire. Au choix: taxi, shared_taxi, okada, keke, bus, ridehail, boat. |
routes[].fares[].service | string | |
routes[].fares[].currency | string | Obligatoire. Au choix: NGN, GHS, XOF. |
routes[].fares[].low | integer | Obligatoire. |
routes[].fares[].typical | integer | Obligatoire. |
routes[].fares[].high | integer | Obligatoire. |
routes[].fares[].text | string | Obligatoire. |
routes[].fares[].perPerson | boolean | Obligatoire. |
routes[].fares[].charter | boolean | Obligatoire. |
routes[].fares[].night | boolean | |
routes[].fares[].rush | boolean | |
routes[].fares[].rain | boolean | |
routes[].fares[].basis | string | Obligatoire. Au choix: crowd, guide. |
routes[].fares[].reports | integer | Obligatoire. |
routes[].fares[].durationS | number | Obligatoire. |
routes[].fares[].openingOffer | integer | Là où les prix se marchandent : une bonne première offre. |
routes[].fares[].sources | string (uri)[] | |
waypoints | object[] | Obligatoire. Où chaque point de passage a été placé sur l’itinéraire, dans l’ordre. |
waypoints[].location | Point | Obligatoire. |
waypoints[].location.type | string | Obligatoire. |
waypoints[].location.coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
waypoints[].postcode | string | |
waypoints[].entrance | string | |
mode | string | Obligatoire. Au choix: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle, boat, train. Par défaut: drive. |
warnings | string[] | |
unconfirmedBans | Ban[] | |
unconfirmedBans[].id | string | Obligatoire. |
unconfirmedBans[].zone | string | Obligatoire. |
unconfirmedBans[].scope | string | Obligatoire. |
unconfirmedBans[].hours | string | |
unconfirmedBans[].since | string | |
unconfirmedBans[].source | string (uri) | |
unconfirmedBans[].where | string | Au choix: origin, destination, stop, route. |
unconfirmedBans[].walkM | number | |
attribution | string | Obligatoire. |
{
"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"
}Erreurs
defaultErreur
Temps de trajet de plusieurs origines vers plusieurs destinations (par élément)
POST https://nways.ng/maps/v1/routes/matrix
Jusqu’à 50 départs et 50 arrivées, 625 éléments (départs × arrivées), chacun facturé comme une unité route_matrix. Modes drive, van, walk, bicycle ; okada, keke et danfo respectent leurs interdictions comme /routes/compute (un élément qui part d’une zone interdite ou y arrive est NOT_ALLOWED, avec l’interdiction) ; motorbike et dispatch seulement les interdictions visant toutes les motos. Points à 400 km au plus en voiture, 200 km sinon. Motifs : 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).
Paramètres
| Nom | Où | Type | Description |
|---|---|---|---|
fields | requête | string | Liste séparée par des virgules des champs à garder dans chaque résultat (a.b descend dans les objets ; id est toujours gardé ; * = tous). |
Corps de la requête
| Champ | Type | Description |
|---|---|---|
origins | Waypoint[] | Obligatoire. Au moins 1 éléments, au plus 50 éléments. |
origins[].lat | number | |
origins[].lng | number | |
origins[].postcode | string | |
origins[].ghanaPost | string | |
origins[].plusCode | string | |
origins[].heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
destinations | Waypoint[] | Obligatoire. Au moins 1 éléments, au plus 50 éléments. |
destinations[].lat | number | |
destinations[].lng | number | |
destinations[].postcode | string | |
destinations[].ghanaPost | string | |
destinations[].plusCode | string | |
destinations[].heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
mode | string | okada, keke et danfo respectent leurs interdictions (comme /routes/compute) ; motorbike et dispatch (motos de coursiers) seulement les interdictions visant toutes les motos. Au choix: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle. Par défaut: drive. |
allowBans | string[] |
curl -X POST "https://nways.ng/maps/v1/routes/matrix" \
-H "X-NWays-Api-Key: VOTRE_CLE_API" \
-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"}'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()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()Réponse
La matrice
| Champ | Type | Description |
|---|---|---|
elements | object[] | Obligatoire. |
elements[].originIndex | integer | Obligatoire. |
elements[].destinationIndex | integer | Obligatoire. |
elements[].status | string | Obligatoire. NOT_ALLOWED : le départ ou l’arrivée est dans une zone interdite pour le mode (ban indique laquelle). Au choix: OK, ROUTE_NOT_FOUND, NOT_ALLOWED. |
elements[].durationS | number | Obligatoire. |
elements[].distanceM | number | Obligatoire. |
elements[].ban | Ban | |
elements[].ban.id | string | Obligatoire. |
elements[].ban.zone | string | Obligatoire. |
elements[].ban.scope | string | Obligatoire. |
elements[].ban.hours | string | |
elements[].ban.since | string | |
elements[].ban.source | string (uri) | |
elements[].ban.where | string | Au choix: origin, destination, stop, route. |
elements[].ban.walkM | number | |
origins | Point[] | Obligatoire. |
origins[].type | string | Obligatoire. |
origins[].coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
destinations | Point[] | Obligatoire. |
destinations[].type | string | Obligatoire. |
destinations[].coordinates | number[] | Obligatoire. [lng, lat] Au moins 2 éléments, au plus 2 éléments. |
mode | string | Obligatoire. |
attribution | string | Obligatoire. |
{
"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"
}Erreurs
defaultErreur
Quel véhicule visite quels arrêts, et dans quel ordre
POST https://nways.ng/maps/v1/routes/optimize
Modes comme /routes/matrix : les arrêts situés dans une zone interdite pour le mode ne sont pas attribués et figurent dans notAllowed. Jusqu’à 50 arrêts et 5 véhicules (départ, arrivée facultative, capacité) : le moindre temps total dans la capacité de chaque véhicule, par une heuristique rapide sur les temps de trajet du moteur (sans garantie d’optimum). L’itinéraire de chaque véhicule est calculé comme /routes/compute, sauf si geometry vaut false. Un appel route_optimization. Motifs : 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).
Corps de la requête
| Champ | Type | Description |
|---|---|---|
stops | object[] | Obligatoire. Au moins 1 éléments, au plus 50 éléments. |
stops[].id | string | Obligatoire. |
stops[].location | Waypoint | Obligatoire. Exactement un élément parmi lat et lng, postcode (NIPOST : l’itinéraire mène à sa meilleure entrée), ghanaPost ou plusCode (complet, ou court suivi d’une ville). |
stops[].location.lat | number | |
stops[].location.lng | number | |
stops[].location.postcode | string | |
stops[].location.ghanaPost | string | |
stops[].location.plusCode | string | |
stops[].location.heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
stops[].demand | integer | Par défaut: 1. ≥ 1. |
stops[].serviceS | number | Par défaut: 0. ≥ 0, ≤ 14400. |
vehicles | object[] | Obligatoire. Au moins 1 éléments, au plus 5 éléments. |
vehicles[].id | string | Obligatoire. |
vehicles[].start | Waypoint | Obligatoire. Exactement un élément parmi lat et lng, postcode (NIPOST : l’itinéraire mène à sa meilleure entrée), ghanaPost ou plusCode (complet, ou court suivi d’une ville). |
vehicles[].start.lat | number | |
vehicles[].start.lng | number | |
vehicles[].start.postcode | string | |
vehicles[].start.ghanaPost | string | |
vehicles[].start.plusCode | string | |
vehicles[].start.heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
vehicles[].end | Waypoint | Exactement un élément parmi lat et lng, postcode (NIPOST : l’itinéraire mène à sa meilleure entrée), ghanaPost ou plusCode (complet, ou court suivi d’une ville). |
vehicles[].end.lat | number | |
vehicles[].end.lng | number | |
vehicles[].end.postcode | string | |
vehicles[].end.ghanaPost | string | |
vehicles[].end.plusCode | string | |
vehicles[].end.heading | number | Origine seulement : sens de déplacement (en degrés), pour qu’un véhicule en mouvement ne commence pas par un demi-tour. |
vehicles[].capacity | integer | 0 = aucune limite Par défaut: 0. ≥ 0. |
mode | string | okada, keke et danfo respectent leurs interdictions (comme /routes/compute) ; motorbike et dispatch (motos de coursiers) seulement les interdictions visant toutes les motos. Au choix: drive, van, okada, motorbike, dispatch, keke, danfo, walk, bicycle. Par défaut: drive. |
allowBans | string[] | |
geometry | boolean | Par défaut: true. |
lang | string | Au choix: en, fr, pt. |
curl -X POST "https://nways.ng/maps/v1/routes/optimize" \
-H "X-NWays-Api-Key: VOTRE_CLE_API" \
-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"}'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()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()Réponse
Le plan
| Champ | Type | Description |
|---|---|---|
routes | object[] | Obligatoire. |
routes[].vehicle | string | Obligatoire. |
routes[].stops | string[] | Obligatoire. Ids des arrêts dans l’ordre de visite |
routes[].durationS | number | Obligatoire. |
routes[].distanceM | number | Obligatoire. |
routes[].serviceS | number | Obligatoire. |
routes[].load | integer | Obligatoire. |
routes[].arrivalsS | number[] | Obligatoire. Secondes entre le départ et chaque arrêt |
routes[].route | Route | |
routes[].route.distanceM | number | Obligatoire. |
routes[].route.durationS | number | Obligatoire. |
routes[].route.staticDurationS | number | Obligatoire. Sans le trafic en direct |
routes[].route.trafficDelayS | number | Obligatoire. Ce que le trafic et les incidents ajoutent en ce moment (traffic_aware). |
routes[].route.speedSource | string | Au choix: live, typical, estimated. |
routes[].route.summary | string | |
routes[].route.geometry | LineString | Obligatoire. |
routes[].route.geometry.type | string | Obligatoire. |
routes[].route.geometry.coordinates | number[][] | Obligatoire. |
routes[].route.legs | Leg[] | Obligatoire. Un par tronçon entre deux arrêts. |
routes[].route.legs[].distanceM | number | Obligatoire. |
routes[].route.legs[].durationS | number | Obligatoire. |
routes[].route.steps | Step[] | Obligatoire. |
routes[].route.steps[].maneuver | string | Obligatoire. depart, arrive, continue, left, right, slight_left, sharp_right, uturn_left, roundabout_enter, ferry_enter, … (autre) |
routes[].route.steps[].instruction | string | Obligatoire. |
routes[].route.steps[].distanceM | number | Obligatoire. |
routes[].route.steps[].durationS | number | Obligatoire. |
routes[].route.steps[].streetNames | string[] | |
routes[].route.steps[].startIndex | integer | Obligatoire. Index dans geometry.coordinates |
routes[].route.steps[].endIndex | integer | Obligatoire. |
routes[].route.steps[].roundaboutExit | integer | |
routes[].route.steps[].toward | string[] | |
routes[].route.steps[].atTrafficLight | boolean | |
routes[].route.steps[].crossing | string | À pied : footbridge, underpass, zebra, signals, crossing, junction |
routes[].route.segments | object[] | Trajets qui changent de mode de déplacement (train, bateau, okada avec une marche au-delà d’une interdiction). |
routes[].route.segments[].mode | string | Obligatoire. Au choix: walk, okada, drive, train, boat. |
routes[].route.segments[].line | string | |
routes[].route.segments[].from | string | Obligatoire. |
routes[].route.segments[].to | string | Obligatoire. |
routes[].route.segments[].distanceM | number | Obligatoire. |
routes[].route.segments[].durationS | number | Obligatoire. |
routes[].route.segments[].waitS | number | |
routes[].route.segments[].stops | integer | |
routes[].route.segments[].scheduled | boolean | |
routes[].route.segments[].estimated | boolean | |
routes[].route.segments[].fare | string | |
routes[].route.segments[].note | string | |
routes[].route.segments[].geometry | LineString | Obligatoire. |
routes[].route.congestion | object[] | |
routes[].route.congestion[].startIndex | integer | |
routes[].route.congestion[].endIndex | integer | |
routes[].route.congestion[].level | string | |
routes[].route.tolls | object | |
routes[].route.tolls.gates | object[] | |
routes[].route.tolls.total | object | |
routes[].route.tolls.unknownPrices | integer | |
routes[].route.borderCrossings | object[] | |
routes[].route.borderCrossings[].from | string | |
routes[].route.borderCrossings[].to | string | |
routes[].route.borderCrossings[].location | Point | |
routes[].route.borderCrossings[].atM | integer | |
routes[].route.borderCrossings[].post | string | |
routes[].route.borderCrossings[].clockChangeH | number | |
routes[].route.vehicleRules | object | Trajets en okada, keke et danfo |
routes[].route.vehicleRules.vehicle | string | Au choix: okada, motorbike, keke, danfo. |
routes[].route.vehicleRules.avoided | Ban[] | |
routes[].route.vehicleRules.advice | Ban[] | |
routes[].route.vehicleRules.endBan | Ban | |
routes[].route.vehicleRules.allowedByRequest | Ban[] | |
routes[].route.vehicleRules.reported | object[] | |
routes[].route.lastMile | object | |
routes[].route.lastMile.stopAt | Point | |
routes[].route.lastMile.stopName | string | |
routes[].route.lastMile.mode | string | |
routes[].route.lastMile.distanceM | number | |
routes[].route.lastMile.durationS | number | |
routes[].route.lastMile.geometry | LineString | |
routes[].route.access | object | |
routes[].route.access.kind | string | Au choix: estate, government, military, police, gate. |
routes[].route.access.text | string | |
routes[].route.access.name | string | |
routes[].route.access.gate | Point | |
routes[].route.access.dropOffAtGate | boolean | |
routes[].route.roadCondition | object | |
routes[].route.roadCondition.roughM | number | |
routes[].route.country | string | |
routes[].route.warnings | string[] | |
routes[].route.fares | FareEstimate[] | |
routes[].route.fares[].mode | string | Obligatoire. Au choix: taxi, shared_taxi, okada, keke, bus, ridehail, boat. |
routes[].route.fares[].service | string | |
routes[].route.fares[].currency | string | Obligatoire. Au choix: NGN, GHS, XOF. |
routes[].route.fares[].low | integer | Obligatoire. |
routes[].route.fares[].typical | integer | Obligatoire. |
routes[].route.fares[].high | integer | Obligatoire. |
routes[].route.fares[].text | string | Obligatoire. |
routes[].route.fares[].perPerson | boolean | Obligatoire. |
routes[].route.fares[].charter | boolean | Obligatoire. |
routes[].route.fares[].night | boolean | |
routes[].route.fares[].rush | boolean | |
routes[].route.fares[].rain | boolean | |
routes[].route.fares[].basis | string | Obligatoire. Au choix: crowd, guide. |
routes[].route.fares[].reports | integer | Obligatoire. |
routes[].route.fares[].durationS | number | Obligatoire. |
routes[].route.fares[].openingOffer | integer | Là où les prix se marchandent : une bonne première offre. |
routes[].route.fares[].sources | string (uri)[] | |
unassigned | string[] | Obligatoire. |
notAllowed | object[] | Arrêts, ou départs et arrivées de véhicules, situés dans une zone interdite pour le mode. |
notAllowed[].stop | string | |
notAllowed[].vehicle | string | |
notAllowed[].ban | Ban | Obligatoire. |
notAllowed[].ban.id | string | Obligatoire. |
notAllowed[].ban.zone | string | Obligatoire. |
notAllowed[].ban.scope | string | Obligatoire. |
notAllowed[].ban.hours | string | |
notAllowed[].ban.since | string | |
notAllowed[].ban.source | string (uri) | |
notAllowed[].ban.where | string | Au choix: origin, destination, stop, route. |
notAllowed[].ban.walkM | number | |
durationS | number | Obligatoire. |
mode | string | Obligatoire. |
attribution | string | Obligatoire. |
{
"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"
}Erreurs
defaultErreur