Document Web Service Guides Routes

Routes API

Provide directions for transit, driving, or walking between multiple locations.

Because road networks, data, and algorithms can change over time, routing requests for the same start and end points may yield different results after a period of time.

Prompt

The Routes API for both domestic and overseas addresses shares the same endpoint. The overseas Web Services API is categorized as a premium service requiring prior authorization. For access requests, submit a business consultation through the official support ticket system.

Application 

With the Routes API, you can:

  • Search for directions across multiple transportation modes, including transit, driving, and walking.
  • Generate multi-part directions using a series of waypoints.
  • Specify origins, destinations, and waypoints using latitude/longitude coordinates only.

The API calculates the most efficient routes, primarily optimizing for travel time. It also considers additional factors such as distance, number of turns, and other relevant criteria to determine the optimal route.

Guidelines

1
Step 1
Apply for a 【Web Service API】Key
2
Step 2
Enable overseas permissions for the applied Key by submitting a ticket to request overseas permissions
3
Step 3
Construct the HTTP request URL, including the Key obtained in Step 1 as a required parameter
4
Step 4
Receive and parse the data returned from the HTTP request (in JSON or XML format)
Unless otherwise specified, all input parameters and output data are encoded in UTF-8

Compute Routes For Driving

Compute Routes For Driving API Service URL

URL

Request Method

https://sg-restapi.opnavi.com/v3/direction/driving?parameters

GET

The parameters represent both required and optional parameters. All parameters are separated by the ampersand character (&). The list below enumerates these parameters and their usage rules.

Request Parameters

Parameter Name

Description

Specification

Mandatory

Default

key

Service Authorization Token

Applying for a Web Service API Key and Submitting a Work Order for Overseas Permissions on Amap Map Official Website

Mandatory

None

origin

Starting Point

Please provide the starting point in the following format: longitude first, followed by latitude, separated by a comma. Ensure that both the longitude and latitude do not exceed 6 decimal places.

Note‌: If either the starting point or destination is an overseas coordinate, the API will return overseas routes results.

Mandatory

None

destination

Destination

Please specify the destination in the following format: longitude first, followed by latitude, separated by a comma. Ensure that both the longitude and latitude do not exceed 6 decimal places.

Mandatory

None

origin_id

Start Point POI ID

When the starting point is a Point of Interest (POI), it is recommended to provide this value to enhance route accuracy.

Optional

None

destination_id

Destination POI ID

When the destination is a Point of Interest (POI), it is recommended to provide this value to enhance route accuracy.

Optional

None

waypoints

Waypoints

For waypoints, please use the following format: longitude and latitude are separated by a comma, with the longitude first and latitude second. Ensure that decimal places do not exceed 6 digits. Separate multiple coordinates with a semicolon.

Maximum Limit‌: A maximum of 16 coordinates can be entered. If multiple waypoints are provided, they will be routed in the order specified by the user.

Optional

None

Strategy

Route Planning Strategy

32: Default Recommendation

0: Speed Priority (only one route returned), this route may not be the shortest

1: Cost Priority (only one route returned), avoids toll roads and is the least time-consuming route

33: Avoid congestion 

34: Highway priority 

35: Avoid highways 

36: Less tolls 

37: Main road priority 

38: Fastest speed 

39: Avoid congestion + Highway priority 

40: Avoid congestion + Avoid highways 

41: Avoid congestion + Less tolls 

42: Less tolls + Avoid highways 

43: Avoid congestion + Less tolls + Avoid highways 

44: Avoid congestion + Main road priority 

45: Avoid congestion + Fastest speed

Optional

32

langCode

Return result language

Default is zh, optional: zh, en;

Optional

None

sig

Digital Signature

Methods for Obtaining and Using Digital Signatures

Optional

None

callback

Callback Function

The callback value is a function name defined by the user.

Optional

None

Examples

https://sg-restapi.opnavi.com/v3/direction/driving?origin=103.988795,1.354462&destination=103.858456,1.302265&key=<your key>

Response Parameters Description

Name

Description

Specification

status

Result Status Value, Value is 0 or 1

0: Request failed; 1: Request succeeded

info

Return Status Description

When status is 0, specific error reasons will be returned in info. Otherwise, "OK" will be returned. For details, refer to theinfo status table.

count

Number of Driving Route Planning Solutions

route

Driving Route Planning Information List

 

origin

Starting Coordinates

Rule: lon, lat (longitude, latitude), separated by ",", e.g., 117.500244, 40.417801, with no more than 6 decimal places for coordinates

destination

Destination Coordinates

Rule: lon, lat (longitude, latitude), separated by ",", e.g., 117.500244, 40.417801, with no more than 6 decimal places for coordinates

taxi_cost

Taxi Fare

Unit: Yuan, Note: Only returned when extensions=all

paths

Driving Transfer Plan

 

path

Driving Transfer Plan

distance

Driving Distance

Unit: Meters

duration

Estimated Travel Time

Unit: Seconds

strategy

Navigation Strategy

tolls

This navigation route has toll charges

Unit: Yuan

restriction

Traffic Restriction Result

0 means the traffic restriction has been avoided or there is no restriction, i.e., there are no restricted sections on this route. 1 means the traffic restriction cannot be avoided, i.e., there are restricted sections on this route.

traffic_lights

Number of Traffic Lights

toll_distance

Toll Road Distance

steps

Navigation Segment

 

step

Navigation Segment

Details see Navigation Step List

  • Navigation Step List

Name

Description

Specification

instruction

Driving Instructions

orientation

Direction

road

Road Name

distance

Distance of this road section

Unit: Meter

tolls

This section is tolled

Unit: Yuan

toll_distance

Distance of toll road section

Unit: Meter

toll_road

Main toll roads

polyline

Coordinate string of this road section

Format as coordinate string, e.g., 116.481247,39.990704;116.481270,39.990726

action

Main navigation actions

See the driving action list for details

assistant_action

Navigation assistance actions

See the driving action list for details

tmcs

Driving navigation details

It contains TMC objects

distance

The length of this road

Unit: meter

status

Traffic condition of this road section

Unknown, clear, slow, congested, severely congested

polyline

The trajectory of this road section

Specification: x1,y1;x2,y2

cities

Route Administrative Divisions

name

Name

citycode

Passing City Codes

adcode

Passing Region Codes

districts

name

Passing County/District Names

adcode

Passing district adcode

  • Driving action list

Note: The following information will only be returned when extensions=all

Main action list

No basic navigation actions

Turn left

Turn right

Drive to the front left

Drive to the front right

Drive to the rear left

Drive to the rear right

Make a U-turn to the left

Go straight

Keep left

Keep right

Enter the roundabout

Exit the roundabout

Decelerate

Assistance action list

Non-assisted navigation action

Entering the main road

Entering the service road

Entering the highway

Entering the ramp

Entering the tunnel

Enter the middle fork

Enter the right fork

Enter the left fork

Enter the right-turn lane

Enter the left-turn lane

Enter the middle lane

Enter the right lane

Enter the left lane

Keep right to enter the service road

Keep left to enter the service road

Keep right to enter the main road

Keep left to enter the main road

Keep right to enter the right-turn lane

Enter the ferry

Exit the ferry

Continue on the current road

Drive along the side road

Drive along the main road

Arrive at the exit

Arrive at the service area

Arrived at the toll booth

Arrived at the waypoint

Arrived at the destination

Turn left around the roundabout

Turn right around the roundabout

Go straight around the roundabout

Make a U-turn around the roundabout

Small roundabout, do not count exits

At the complex intersection, take the first exit on the right

At the complex intersection, take the second exit on the right

At the complex intersection, take the third exit on the right

At the complex intersection, take the fourth exit on the right

At the complex intersection, take the fifth exit on the right

At the complex intersection, take the first exit on the left

At the complex intersection, take the second exit on the left

At the complex intersection, take the third exit on the left

At the complex intersection, take the fourth exit on the left 

At the complex intersection, take the fifth exit on the left

Enter the U-turn lane

Compute Routes Matrix

Compute Routes Matrix(M to N),The Routes API is a service that accepts an HTTPS request and returns either the ideal route between two locations, or distances and travel times for a matrix of routes between different origin and destination locations.

Application

  • Routes from a location to a single or multiple destinations
  • A matrix of possible routes between many start and end locations.

Compute Routes Matrix API Service URL

URL

Request Method 

https://sg-restapi.opnavi.com/v5/distance/matrix?parameters

POST

The parameters represent both required and optional parameters. All parameters are separated by the ampersand character (&). The list below enumerates these parameters and their usage rules.

Request Parameters

Parameter Name

Description 

Specification

Mandatory

Default

key

Service Authorization Token

Applying for a Web Service API Key and Submitting a Work Order for Overseas Permissions on Amap Map Official Website

Mandatory

None

origins

Starting point

lng,lat(longitude first; "," separated; latitude last)e.g., 117.500244,40.417801 It is recommended that the latitude and longitude do not exceed 6 decimal places; format as x,y. Format as x,y ; x,y ; x,y..... Latitude and longitude are separated by ";"; supports up to 25 starting points

Mandatory

None

(If there are more than 6 digits after the decimal point, truncate it)

destinations

Destination

lng,lat (longitude first; "," separated; latitude last) e.g., 117.500244,40.417801 It is recommended that the latitude and longitude do not exceed 6 decimal places; format as x,y ; x,y ; x,y..... Latitude and longitude are separated by ";"; supports up to 25 destinations

Mandatory

None

(If there are more than 6 digits after the decimal point, truncate it)

travelMode

Transportation mode

Drive

Optional

Drive

routingPreference

Route planning strategy

1:Speed First

Optional

1

departureTime

Departure time (in seconds)

Optional. The departure time. 

If you don't set this value, then this value defaults to the time that you made the request

Only future times are supported, with a maximum of 7 days

Unix timestamp

Optional

None

Examples

https://sg-restapi.opnavi.com/v5/distance/matrix?key=<your key>&origins=126.983319,35.806658&destinations=126.983319,35.806658;127.000000,36.000000;127.100000,36.100000;127.200000,36.200000;127.300000,36.300000;127.400000,36.400000;127.500000,36.500000;127.600000,36.600000;127.700000,36.700000;127.800000,36.800000&routingPreference=TRAFFIC_AWARE

Response Parameters Description

Name

Description

Specification

status

Return Result Status Value

The value is 0 or 1, 0 means failure; 1 means success

info

Return Status Description

Return status description, when status is 0, info returns the reason for the error, otherwise returns "OK".

infocode

Status Code

Return status description, 10000 represents correct, refer to info status table for details

routes

Compute Routes

route

Compute Routes

originIndex

Origin Index

1~25

destinationIndex

Destination Index

1~25

status

Return Status Value

0: Success 

1: Exceeds distance limit 

2: Request timeout 

111: Start point matching failure 

112: Via point matching failure 

113: Destination point matching failure 

141: Route calculation failure 

-1: Other

distanceMeters

Distance

Distance (meters)

duration

Duration

Time taken (seconds)