Show Side Bar

Search

This API enables users to obtain address information for roads and buildings, etc. This API is great for web forms or application that can benefit from instant address verification or solutions that want localised POI.

This API takes a text input which can be a building name, road name, bus stop number, or postal code; for example: "Revenue House" or "307987". It returns address information including both latitude, longitude, and x, y coordinates, based on the text input and sorts the results according to their estimated relevance.

Possible Error Responses

400 - Parameter searchVal is invalid.

400 - Please state whether you want to return the geometry. (Y-Yes/N-No)

400 - Please state whether you want to return the address. (Y-Yes/N-No)

400 - Please state a valid page number.

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 exceeded.

HEADER PARAMETERS

AuthorizationstringRequired

API token provided by the Authentication Service.

searchValstringRequired

Keywords entered by users to filter the results

returnGeomstringRequired

Values: Y, N . Enter Y if user wants the geometry value returned.

getAddrDetailsstringRequired

Values: Y, N . Enter Y if user wants address details returned.

pageNuminteger

Optional. Specifies the page to retrieve search results.

GET
/api/common/elastic/search


Sample Request

GET
/api/common/elastic/search?searchVal=200640&returnGeom=Y&getAddrDetails=Y&pageNum=1
1const url = "https://www.onemap.gov.sg/api/common/elastic/search?searchVal=200640&returnGeom=Y&getAddrDetails=Y&pageNum=1"; 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 "found": 1, 3 "totalNumPages": 1, 4 "pageNum": 1, 5 "results": [ 6 { 7 "SEARCHVAL": "640 ROWELL ROAD SINGAPORE 200640", 8 "BLK_NO": "640", 9 "ROAD_NAME": "ROWELL ROAD", 10 "BUILDING": "NIL", 11 "ADDRESS": "640 ROWELL ROAD SINGAPORE 200640", 12 "POSTAL": "200640", 13 "X": "30381.1007417506", 14 "Y": "32195.1006872542", 15 "LATITUDE": "1.30743547948389", 16 "LONGITUDE": "103.854713903431", 17 "LONGTITUDE": "103.854713903431" 18 } 19 ] 20}