OneMap API Client
Python Wrapper Client for the OneMap API
Docs here: https://docs.onemap.sg/
PyPI Link: https://pypi.org/project/onemapsg/
Register for an API key here: https://developers.onemap.sg/signup/
This client:
- Authenticates for a valid API token, and refreshes as needed!
- Returns everything as a nice dictionary!
Example Usage
from onemapsg import OneMapClient
Client = OneMapClient("YOUR_EMAIL", "YOUR_PASSWORD")
Client.search("Dragon View Park")
# Result
'''
{'found': 1,
'totalNumPages': 1,
'pageNum': 1,
'results': [{'SEARCHVAL': 'DRAGON VIEW PARK',
'BLK_NO': '',
'ROAD_NAME': 'NIL',
'BUILDING': 'DRAGON VIEW PARK',
'ADDRESS': 'DRAGON VIEW PARK SINGAPORE',
'POSTAL': 'NIL',
'X': '27415.382888752',
'Y': '31015.7030415982',
'LATITUDE': '1.29676950856585',
'LONGITUDE': '103.828065538017',
'LONGTITUDE': '103.828065538017'}]}
'''
Installation
pip install onemapsg
Credits
-
The OneMap team for a pretty nice API
-
Author: methylDragon
Support my efforts!
Client Interface
Includes the full API as of February 2019, also supports a general API query in case of client depreciation:
Client Specific
-
Initialise Client
-
Client = OneMapClient(email, password)Generates token on init
-
-
Generate New Token
-
get_token(email=None, password=None)Returns:
token, expiry
-
-
General Query
query_api(endpoint, param_dict)
Class Methods
Remember to use them as such! Client.method()
Location Search
- Search
search(search_val, return_geom=True, get_addr_details=True, page_num=1))
- Reverse Geocode (SVY21 and WGS84)
reverse_geocode_SVY21(coordinates, buffer=10, address_type="All", other_features=False)reverse_geocode_WGS84(coordinates, buffer=10, address_type="All", other_features=False)
Coordinate Conversion
- All converters between WGS84, SVY21, and 3857
WGS84_to_EPSG(coordinates)WGS84_to_SVY21(coordinates)SVY21_to_EPSG(coordinates)SVY21_to_WGS84(coordinates)EPSG_to_SVY21(coordinates)EPSG_to_WGS84(coordinates)
Themes
- Check Theme Status
check_theme_status(query_name, date_time)
- Get Theme Info
get_theme_info(query_name)
- Get all Themes
get_all_themes_info(more_info=False)
- Retrieve Themes
retrieve_theme(query_name, extents=None)
Planning Areas
- Get all Planning Areas
get_all_planning_areas(year=None)
- Get Planning Area Names
get_planning_area_names(year=None)
- Get Planning Area Bounds
get_planning_area_bounds(coordinates, year=None)
Population Queries
- Economic Statuses
get_economic_statuses(year, planning_area, gender=None)
- Education Attendance
get_education_attendance(year, planning_area)
- Ethnic Groups
get_ethnic_groups(year, planning_area, gender=None)
- Work Income For Household (Monthly)
get_household_monthly_work_income(year, planning_area)
- Household Size Data
get_household_sizes(year, planning_area)
- Household Structure Data
get_household_structures(year, planning_area)
- Income from Work Data
get_work_income(year, planning_area)
- Population of Industries
get_industries(year, planning_area)
- Language Literacy Data
get_language_literacy(year, planning_area)
- Marital Status Data
get_marital_statuses(year, planning_area, gender=None)
- Mode of Transports to School Data
get_modes_of_transport_to_school(year, planning_area)
- Mode of Transport to Work Data
get_modes_of_transport_to_work(year, planning_area)
- Occupation Data
get_occupations(year, planning_area)
- Age Data
get_age_groups(year, planning_area)
- Religion Data
get_religious_groups(year, planning_area)
- Spoken Language Data
get_spoken_languages(year, planning_area)
- Tenancy Data
get_tenancy(year, planning_area)
- Dwelling Type Household Data
get_dwelling_types(year, planning_area)
- Dwelling Type Population Data
get_population_by_dwelling_types(year, planning_area)
Routing Service
- Get Route
get_route(start_coordinates, end_coordinates, route_type)
- Get Public Transport Route
get_public_transport_route(start_coordinates, end_coordinates, date, time, mode, max_walk_distance=None, num_itineraries=1)
Static Map Generator
- Generate Static Map
generate_static_map(layer_chosen, location, zoom, width, height, polygons=None, lines=None, points=None, color=None, fill_color=None)
OneMap API Client Changelog
v1.0.3 - 2021_07_21
Fixed
get_token()updated for new JSON API
v1.0.2 - 2020_02_10
Fixed
- Fix missing
modeparameter inget_public_transport_route()call
v1.0.1 - 2020_02_10
Changed
- Allow functions that use onemap API tokens internally to continue running when token expiry is detected and token renewal occurs, instead of returning immediately
Fixed
- Fix string formatting bug in
get_route()andget_public_transport_route()
v1.0.0 - 2019_07_09
Added
- Initial release:
- OneMapClient with full API
Metadata
Release files for onemapsg 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onemapsg-1.0.3.tar.gz | 9.4 kB | Without provenance | Details for onemapsg-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onemapsg-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for onemapsg-1.0.3-py3-none-any.whl |
Total release size: 17.1 kB
Release files / onemapsg-1.0.3.tar.gz
| Download URL | onemapsg-1.0.3.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61cc5e2a985152a530d12b41c00a14671e4e4e980b6af633efedb899470d882c
|
|
BLAKE2b-256 checksum How to use checksums |
30c00c128192405193dbdb203906aa1b521b9c5b5e1f98fc136a58690cb2737e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1
|
Release files / onemapsg-1.0.3-py3-none-any.whl
| Download URL | onemapsg-1.0.3-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50f67ce1c5e34e36e67458e744dac96a2ed56dd2e8e61a6eee7dd1ae716de628
|
|
BLAKE2b-256 checksum How to use checksums |
37cc99dc11b473360fe94da32ac4af231ab9dbe97d8d660557e8af95527f91b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1
|
Security for onemapsg 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.