Skip to main content

Python OneMap SG API

https://travis-ci.org/windspeed-io/python-onemapsg.svg?branch=master https://coveralls.io/repos/github/windspeed-io/python-onemapsg/badge.svg?branch=master https://badge.fury.io/py/python-onemapsg.svg

Python Client for OneMap SG v2.

Only supports Python 3.6 and up.

This package can be used in production but is not fully featured yet.

Getting Started

>> from onemapsg import OneMap
>> onemap = OneMap('your-email', 'your-password')
>> search = onemap.search('One Raffles Quay')
# You can work directly with the SearchResult object
>> search.found
1
>> search.page_num
1
>> len(search.results)
1
>> result = search.results[0]  # One Raffles Quay
>> result.address
'1 RAFFLES QUAY ONE RAFFLES QUAY SINGAPORE 048583'
>> result.blk_no
'1'
>> result.building
'ONE RAFFLES QUAY'
>> result.lat_long
('1.28118338714692', '103.851899818913')
>> result.postal
'048583
>> result.road_name
'RAFFLES QUAY'
>> result.search_value
'ONE RAFFLES QUAY'
# You can convert the results to a dictionary too
>> search_as_dict = search.to_dict()
>> from pprint import pprint
>> pprint(search_as_dict)
{'found': 1,
 'page_num': 1,
 'results': [{'address': '1 RAFFLES QUAY ONE RAFFLES QUAY SINGAPORE 048583',
             'blk_no': '1',
             'building': 'ONE RAFFLES QUAY',
             'coordinates': ('30067.9405244123', '29292.2770711072'),
             'lat_long': ('1.28118338714692', '103.851899818913'),
             'postal': '048583',
             'road_name': 'RAFFLES QUAY',
             'search_value': 'ONE RAFFLES QUAY'}],
 'total_num_pages': 1}
>> next_search = onemap.search('Paragon')
>> pprint(next_search.to_dict())
{'found': 7,
 'page_num': 1,
 'results': [{'address': '290 ORCHARD ROAD THE PARAGON SINGAPORE 238859',
             'blk_no': '290',
             'building': 'THE PARAGON',
             'coordinates': ('28282.5637398548', '31801.0936260298'),
             'lat_long': ('1.30387230879998', '103.835857545469'),
             'postal': '238859',
             'road_name': 'ORCHARD ROAD',
             'search_value': 'THE PARAGON'},
             ...
             ...
             ...
 'total_num_pages': 1}
 >> next_result = next_search.results[0]  # Paragon
 # Find the route between One Raffles Quay and Paragon
 >> orq_latlong = ','.join(result.lat_long)
 >> paragon_latlong = ','.join(next_result.lat_long)
 >> route = onemap.route(orq_latlong, paragon_latlong, 'drive')
 >> pprint(route.to_dict())
{'route_geometry': 'uiyFapzxRt@`@lAr@v@b@wAxCMXkAdCi@xAiArBq@xAoAnC_@t@sB|DQT}@fBWh@iChFYd@}C`Ek@n@[Vm@Vc@Jm@Dc@EqAe@i@ZkAbDgAnA}@UMGu@]uEqBOGMEsAe@aEoB{G}CMGKE_Bo@}@UcAEsEVg@BaCNiA|AI\\wAb@qClAWFaBn@u@d@EDKN_@r@g@lBc@hBM~@AZPtBA\\yA~LSvAu@~EUbAq@xBuAk@}BaAm@WuB_A_AGk@BqDoAe@S',
'route_instructions': [['Head',
                        'RAFFLES QUAY',
                        125,
                        '1.281708,103.851687',
                        16,
                        '125m',
                        'South West',
                        'North',
                        'driving',
                        'Head Southwest On Raffles Quay'],
                        ['Right',
                        'CROSS STREET',
                        641,
                        '1.280771,103.851082',
                        73,
                        '641m',
                        'North West',
                        'South West',
                        'driving',
                        'Turn Right Onto Cross Street'],
                        ...
                        ...
                        ['Slight Left',
                        'ORCHARD LINK',
                        60,
                        '1.302314,103.835849',
                        11,
                        '60m',
                        'North',
                        'North East',
                        'driving',
                        'Make A Slight Left To Stay On Orchard Link'],
                        ['Slight Right',
                        'BIDEFORD ROAD',
                        134,
                        '1.302845,103.835865',
                        15,
                        '134m',
                        'North East',
                        'North',
                        'driving',
                        'Continue Slightly Right Onto Bideford Road'],
                        ['Left',
                        'BIDEFORD ROAD',
                        0,
                        '1.303932,103.836371',
                        0,
                        '0m',
                        'North',
                        'North East',
                        'driving',
                        'You Have Arrived At Your Destination, On The Left']],
'route_name': ['UPPER CROSS STREET', 'CLEMENCEAU AVENUE'],
'route_summary': {'end_point': 'BIDEFORD ROAD',
                'start_point': 'RAFFLES QUAY',
                'total_distance': 4163,
                'total_time': 489},
'status': 0,
'status_message': 'Found route between points'}
# You can get the decoded polyline lat longs
>> pprint(route.lat_longs)
[(1.28171, 103.85169),
(1.28144, 103.85152),
(1.28105, 103.85126),
(1.28077, 103.85108),
...
(1.30007, 103.83581),
(1.30018, 103.83547),
(1.30043, 103.83486),
(1.30086, 103.83508),
(1.30149, 103.83541),
(1.30172, 103.83553),
(1.30231, 103.83585),
(1.30263, 103.83589),
(1.30285, 103.83587),
(1.30374, 103.83627),
(1.30393, 103.83637)]

Metadata

Release files for python-onemapsg 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-onemapsg 0.1.1
File Size Uploaded Provenance Actions
python-onemapsg-0.1.1.tar.gz 19.5 kB Without provenance Details for python-onemapsg-0.1.1.tar.gz

Release files / python-onemapsg-0.1.1.tar.gz

Download URL python-onemapsg-0.1.1.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e59c3cfbfacf7794c49cfd34af637d3325dc85f91402732a8194f2064a2dc3d4
BLAKE2b-256 checksum
How to use checksums
4c4474b3605570fbcb81b26d137465a12c40b8bc50a47f3ca1989b41b3dc246e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Security for python-onemapsg 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page