PyOneMap — Python Wrapper for SLA’s OneMap API

Cheng Guan Teo
1 min readAug 14, 2023

--

PyOneMap is a Python package that provides a convenient and easy-to-use interface for interacting with the Singapore Land Authority’s (SLA) OneMap API. With PyOneMap, you can retrieve various geospatial data and information from OneMap’s services directly from your Python code.

This is built using the [API doc](https://www.onemap.gov.sg/apidocs/apidocs) release in 2023. The old API documentation and APIs will be available until 31 August 2023.

Installation:

# pip install pyonemap

Example: Find walking distance between 2 locations:

from pyonemap import OneMap

# Obtain access token using email and password.
response = OneMap.getToken('your_email@email.com', 'your_password')
access_token = response['access_token']

# Instantiate OneMap object for API query.
onemap = OneMap(access_token)

# Search for a address using postal code.
start = onemap.search("380016", 'Y', 'Y')
end = onemap.search("658713", 'Y', 'Y')
route = onemap.routing.route(start["results"][0]["LATITUDE"],start["results"][0]["LONGITUDE"],end["results"][0]["LATITUDE"],end["results"][0]["LONGITUDE"], "walk")
route['route_summary']
# {'start_point': '', 'end_point': '', 'total_time': 11662, 'total_distance': 16198}
Walking distance computed by Google Maps

Cheers!

Source: https://github.com/chengguan/pyonemap

#python #SLA #OneMap

--

--