Show Side Bar

Routing

OneMap has different routing options localised for commuting in Singapore. They include, public transport (PT), drive, walk and cycle.

This API includes calculating the distance for the path, and returning the drawn path between the specified start and end positions depending on the routeType.

Response for total time is in seconds and total distance is in metres.

Return responses have a route_geometry variable that is encoded. Users must use the sample code given if drive or walk is selected (see Decoding route geometry).

Public Transport

This API retrieves travel paths involving public transports. If routeType parameter is set to pt, users are able to choose between 3 modes of public transport. More input parameters (date, time, and mode) will be required for pt.

Parameter maxWalkDistance is the maximum walking distance. Parameter numItineraries may be used to limit the number of results returned.

Possible Error Responses

400 - Please send the access token in the request header as a bearer token.

400 - Please input both latitude and longitude coordinates.

400 - Date format should be in MM-DD-YYYY.

401 - Token has expired: Session expired. Please refresh your token (if still within refresh window) or re-login.

401 - Invalid token: Could not decode token: The token xxx; is an invalid JWS.

403 - Access Forbidden. GET access to component 'xxx' of service 'xxx' is not allowed by this user's role.

429 - API limit(s) exceeded.


HEADER PARAMETERS

AuthorizationstringRequired

API token provided by the Authentication Service.

QUERY PARAMETERS

startstringRequired

The start point in WGS84 latitude, longitude format.

endstringRequired

The end point in WGS84 latitude, longitude format.

routeTypestringRequired

Route types available walk, drive, pt, and cycle. Only lowercase is allowed.

datestringRequired

Date of the selected start point in MM-DD-YYYY.

timestringRequired

Time of the selected start point in [HH][MM][SS], using the 24-hour clock system. [HH] refers to a zero-padded hour between 00 and 23. [MM] refers to a zero-padded minute between 00 and 59. [SS] refers to a zero-padded second between 00 and 59.

modestringRequired

Mode of public transport: TRANSIT, BUS, RAIL. Entry must be specified in UPPERCASE

maxWalkDistancestring

Optional. The maximum walking distance set by the user in metres.

numItinerariesstring

Optional. Limits the number of return results: 1 to 3.

GET
/api/public/routingsvc/route


Sample Request

GET
/api/public/routingsvc/route?start=1.320981%2C103.844150&end=1.326762%2C103.8559&routeType=pt&date=08-13-2023&time=07%3A35%3A00&mode=TRANSIT&maxWalkDistance=1000&numItineraries=3
1const url = "https://www.onemap.gov.sg/api/public/routingsvc/route?start=1.320981%2C103.844150&end=1.326762%2C103.8559&routeType=pt&date=08-13-2023&time=07%3A35%3A00&mode=TRANSIT&maxWalkDistance=1000&numItineraries=3"; 2const authToken = '**********************'; // Replace with your access token 3 4fetch(url, { 5 method: 'GET', 6 headers: { 7 'Authorization': `${authToken}`, // API token for authorization 8 } 9}) 10.then(response => response.json()) // Parse response as JSON 11.then(data => console.log(data)) // Log the data to the console 12.catch(error => console.error('Error:', error)); // Log any errors

Sample Response
1{ 2 "requestParameters": { 3 "date": "07-11-2023", 4 "preferredRoutes": "1__CC,1__DT,1__EW,1__NE,1__NS,1__PE,1__PW,1__SE,1__SS,1__SW,1__CG,1__BP", 5 "walkReluctance": "2", 6 "fromPlace": "1.320981,103.844150", 7 "transferPenalty": "7200", 8 "maxWalkDistance": "1000", 9 "maxTransfers": "3", 10 "otherThanPreferredRoutesPenalty": "0", 11 "numItineraries": "3", 12 "waitAtBeginningFactor": "0.5", 13 "mode": "TRANSIT,WALK", 14 "arriveBy": "false", 15 "showIntermediateStops": "true", 16 "toPlace": "1.326762,103.8559", 17 "time": "7:35am" 18 }, 19 "plan": { 20 "date": 1689032100000, 21 "from": { 22 "name": "Origin", 23 "lon": 103.84415, 24 "lat": 1.320981, 25 "orig": "", 26 "vertexType": "NORMAL" 27 }, 28 "to": { 29 "name": "Destination", 30 "lon": 103.8559, 31 "lat": 1.326762, 32 "orig": "", 33 "vertexType": "NORMAL" 34 }, 35 "itineraries": [ 36 { 37 "duration": 1027, 38 "startTime": 1689032345000, 39 "endTime": 1689033372000, 40 "walkTime": 487, 41 "transitTime": 538, 42 "waitingTime": 2, 43 "walkDistance": 553.93201502772, 44 "walkLimitExceeded": false, 45 "elevationLost": 0, 46 "elevationGained": 0, 47 "transfers": 0, 48 "legs": [ 49 { 50 "startTime": 1689032345000, 51 "endTime": 1689032745000, 52 "departureDelay": 0, 53 "arrivalDelay": 0, 54 "realTime": false, 55 "distance": 449.171, 56 "pathway": false, 57 "mode": "WALK", 58 "route": "", 59 "agencyTimeZoneOffset": 28800000, 60 "interlineWithPreviousLeg": false, 61 "from": { 62 "name": "Origin", 63 "lon": 103.84415, 64 "lat": 1.320981, 65 "departure": 1689032345000, 66 "orig": "", 67 "vertexType": "NORMAL" 68 }, 69 "to": { 70 "name": "REVIVAL CTR CH", 71 "stopId": "FERRY:50111", 72 "stopCode": "50111", 73 "lon": 103.846554958, 74 "lat": 1.31875833025, 75 "arrival": 1689032745000, 76 "departure": 1689032746000, 77 "stopIndex": 36, 78 "stopSequence": 38, 79 "vertexType": "TRANSIT" 80 }, 81 "legGeometry": { 82 "points": "s~`GmayxRa@a@VSDE@CFEHIPOBC@CA?@A\\Y@CnAmAHIBCDEDEDCDCJGFCJCFAHALAh@El@GXCXCF?TCAGC[?EB?JCPA@A@A?AEa@UaAAMB?", 83 "length": 46 84 }, 85 "rentedBike": false, 86 "transitLeg": false, 87 "duration": 400, 88 "intermediateStops": [], 89 "steps": [ 90 { 91 "distance": 449.171, 92 "relativeDirection": "DEPART", 93 "streetName": "path", 94 "absoluteDirection": "NORTHEAST", 95 "stayOn": false, 96 "area": false, 97 "bogusName": false, 98 "lon": 103.84423137491, 99 "lat": 1.3209015602086, 100 "elevation": [] 101 } 102 ], 103 "numIntermediateStops": 1 104 }, 105 { 106 "startTime": 1689032746000, 107 "endTime": 1689033284000, 108 "departureDelay": 0, 109 "arrivalDelay": 0, 110 "realTime": false, 111 "distance": 2172.9761154541, 112 "pathway": false, 113 "mode": "BUS", 114 "route": "124", 115 "agencyName": "SBS Transit", 116 "agencyUrl": "http://www.sbstransit.com.sg/", 117 "agencyTimeZoneOffset": 28800000, 118 "routeType": 3, 119 "routeId": "124", 120 "interlineWithPreviousLeg": false, 121 "agencyId": "SBST", 122 "tripId": "124-2-1004", 123 "serviceDate": "20230711", 124 "from": { 125 "name": "REVIVAL CTR CH", 126 "stopId": "FERRY:50111", 127 "stopCode": "50111", 128 "lon": 103.846554958, 129 "lat": 1.31875833025, 130 "arrival": 1689032745000, 131 "departure": 1689032746000, 132 "stopIndex": 36, 133 "stopSequence": 38, 134 "vertexType": "TRANSIT" 135 }, 136 "to": { 137 "name": "ST. MICHAEL'S TER", 138 "stopId": "FERRY:52499", 139 "stopCode": "52499", 140 "lon": 103.855372113, 141 "lat": 1.32603759751, 142 "arrival": 1689033284000, 143 "departure": 1689033285000, 144 "stopIndex": 42, 145 "stopSequence": 44, 146 "vertexType": "TRANSIT" 147 }, 148 "legGeometry": { 149 "points": "ep`GcpyxRKaACQWuBMaASkBGc@Iy@OuAOuAKmAKgAAs@Ae@?M?O@y@BqCEq@O{@Qm@KSGKcCNM?{BL??kBJQ@qCN{@NKiFE}BAg@?I?C@OVk@H_@?e@CKEWOYQQoB}AwAgA{BgBsB{AiAw@GKAODQj@s@j@s@@_A{AyA??m@k@SGS?[Nq@|@o@x@qAhBi@t@??_AnAOTaARJl@[hDE`@OjB@JHJpClAd@\\^Mh@w@jAv@", 150 "length": 80 151 }, 152 "routeShortName": "124", 153 "routeLongName": "SBST BUS 124", 154 "rentedBike": false, 155 "transitLeg": true, 156 "duration": 538, 157 "intermediateStops": [ 158 { 159 "name": "NATL SKIN CTR", 160 "stopId": "FERRY:50121", 161 "stopCode": "50121", 162 "lon": 103.849339232, 163 "lat": 1.31930304159, 164 "arrival": 1689032789000, 165 "departure": 1689032819000, 166 "stopIndex": 37, 167 "stopSequence": 39, 168 "vertexType": "TRANSIT" 169 }, 170 { 171 "name": "OPP BLK 104", 172 "stopId": "FERRY:50229", 173 "stopCode": "50229", 174 "lon": 103.852834896, 175 "lat": 1.3209576472, 176 "arrival": 1689032891000, 177 "departure": 1689032921000, 178 "stopIndex": 38, 179 "stopSequence": 40, 180 "vertexType": "TRANSIT" 181 }, 182 { 183 "name": "BLK 82", 184 "stopId": "FERRY:50991", 185 "stopCode": "50991", 186 "lon": 103.856261453, 187 "lat": 1.32337986006, 188 "arrival": 1689033007000, 189 "departure": 1689033037000, 190 "stopIndex": 39, 191 "stopSequence": 41, 192 "vertexType": "TRANSIT" 193 }, 194 { 195 "name": "BLK 29", 196 "stopId": "FERRY:52129", 197 "stopCode": "52129", 198 "lon": 103.859381111, 199 "lat": 1.32544666698, 200 "arrival": 1689033109000, 201 "departure": 1689033139000, 202 "stopIndex": 40, 203 "stopSequence": 42, 204 "vertexType": "TRANSIT" 205 }, 206 { 207 "name": "BET BLKS 33/34", 208 "stopId": "FERRY:52109", 209 "stopCode": "52109", 210 "lon": 103.858171111, 211 "lat": 1.32697666701, 212 "arrival": 1689033182000, 213 "departure": 1689033212000, 214 "stopIndex": 41, 215 "stopSequence": 43, 216 "vertexType": "TRANSIT" 217 } 218 ], 219 "steps": [], 220 "numIntermediateStops": 6 221 }, 222 { 223 "startTime": 1689033285000, 224 "endTime": 1689033372000, 225 "departureDelay": 0, 226 "arrivalDelay": 0, 227 "realTime": false, 228 "distance": 104.455, 229 "pathway": false, 230 "mode": "WALK", 231 "route": "", 232 "agencyTimeZoneOffset": 28800000, 233 "interlineWithPreviousLeg": false, 234 "from": { 235 "name": "ST. MICHAEL'S TER", 236 "stopId": "FERRY:52499", 237 "stopCode": "52499", 238 "lon": 103.855372113, 239 "lat": 1.32603759751, 240 "arrival": 1689033284000, 241 "departure": 1689033285000, 242 "stopIndex": 42, 243 "stopSequence": 44, 244 "vertexType": "TRANSIT" 245 }, 246 "to": { 247 "name": "Destination", 248 "lon": 103.8559, 249 "lat": 1.326762, 250 "arrival": 1689033372000, 251 "orig": "", 252 "vertexType": "NORMAL" 253 }, 254 "legGeometry": { 255 "points": "u~aGag{xRBEYQk@a@GE[IOKMIMI", 256 "length": 9 257 }, 258 "rentedBike": false, 259 "transitLeg": false, 260 "duration": 87, 261 "intermediateStops": [], 262 "steps": [ 263 { 264 "distance": 104.455, 265 "relativeDirection": "DEPART", 266 "streetName": "path", 267 "absoluteDirection": "NORTHEAST", 268 "stayOn": false, 269 "area": false, 270 "bogusName": true, 271 "lon": 103.85537211286, 272 "lat": 1.3260375973322, 273 "elevation": [] 274 } 275 ], 276 "numIntermediateStops": 1 277 } 278 ], 279 "tooSloped": false, 280 "fare": "0.99" 281 },... 282 ] 283 }, 284 "debugOutput": { 285 "precalculationTime": 135, 286 "pathCalculationTime": 106, 287 "pathTimes": [ 288 59, 289 33, 290 14 291 ], 292 "renderingTime": 1, 293 "totalTime": 242, 294 "timedOut": false 295 }, 296 "elevationMetadata": { 297 "ellipsoidToGeoidDifference": 7.3773084368695, 298 "geoidElevation": false 299 } 300 }

Walk/Drive/Cycle

This API retrieves walking, driving or cycling path options for given start and end latitudes and longitudes and setting routeType to walk, drive or cycle.

Possible Error Responses

400 - Please send the access token in the request header as a bearer token.

400 - Your starting/ending location is not provided.

400 - Please specify a route type.(drive/pt/walk/cycle).

401 - Token has expired: Session expired. Please refresh your token (if still within refresh window) or re-login.

401 - Invalid token: Could not decode token: The token xxx; is an invalid JWS.

403 - Access Forbidden. GET access to component 'xxx' of service 'xxx' is not allowed by this user's role.

429 - API limit(s) exceeded.


HEADER PARAMETERS

AuthorizationstringRequired

API token provided by the Authentication Service.

QUERY PARAMETERS

startstringRequired

The start point in WGS84 latitude, longitude format.

endstringRequired

The end point in WGS84 latitude, longitude format.

routeTypestringRequired

Route types available walk, drive, pt, and cycle. Only lowercase is allowed.

GET
/api/public/routingsvc/route


Sample Request

GET
/api/public/routingsvc/route?start=1.319728%2C103.8421&end=1.319728905%2C103.8421581&routeType=walk
1const url = "https://www.onemap.gov.sg/api/public/routingsvc/route?start=1.319728%2C103.8421&end=1.319728905%2C103.8421581&routeType=walk"; 2 const authToken = '**********************'; // Replace with your access token 3 4 fetch(url, { 5 method: 'GET', 6 headers: { 7 'Authorization': `${authToken}`, // API token for authorization 8 } 9 }) 10 .then(response => response.json()) // Parse response as JSON 11 .then(data => console.log(data)) // Log the data to the console 12 .catch(error => console.error('Error:', error)); // Log any errors

Sample Response
1{ 2 "status_message": "Found route between points", 3 "route_geometry": "{u`GktxxR?G", 4 "status": 0, 5 "route_instructions": [ 6 [ 7 "Left", 8 "", 9 5, 10 "1.319498,103.842142", 11 3, 12 "5m", 13 "East", 14 "North", 15 "walking", 16 "Head East" 17 ], 18 [ 19 "Left", 20 "", 21 0, 22 "1.319502,103.842179", 23 0, 24 "0m", 25 "North", 26 "East", 27 "walking", 28 "You Have Arrived At Your Destination, On The Left" 29 ] 30 ], 31 "route_name": [ 32 "" 33 ], 34 "route_summary": { 35 "start_point": "", 36 "end_point": "", 37 "total_time": 3, 38 "total_distance": 5 39 } 40}