TransportNSW
Python lib to access Transport NSW information.
How to Use
Get an API Key
An OpenData account and API key is required to request the data. More information on how to create the free account can be found here: https://opendata.transport.nsw.gov.au/user-guide .
Get the stop and line
The libary will expect at least stop id to request the next leave events. The easieste way to get the ID is using Google Maps and clicking on one of the bus, train or ferry stops. The information pane one the left will show the relevant stop ID.
Another source for the stop ID and line is https://transportnsw.info/stops#/. It provides the option to search for a stop and the corresponding lines leaving from there.
Sample Code
The following example will request the next leave event for the bus route/line 199 from stop ID 209516.
Code:
from TransportNSW import TransportNSW
ptnsw1 = TransportNSW.TransportNSW()
journey = tnsw.get_departures('209516', '199', '', 'YOUR_API_KEY')
print(journey)
Result:
{'stop_id': '209516', 'route': '199', 'due': 4, 'delay': 0, 'real_time': 'n', 'destination': 'Palm Beach'}
- route: bus, train, ferry number
- due: minutes till next leave
- real_time: flag if the leave event has real_time information
- delay: delay in minutes from the scheduled leave time
- destination: end point of the route
Leaving the line field empty will return any bus/train/ferry leaving next from a given stop. Code:
journey = tnsw.get_departures('209516', '', '', 'YOUR_API_KEY')
Setting a destination will return all lines going there from the stop_id. Example for ferries leaving Balmain Warf towards Circular Quay Code:
journey = tnsw.get_departures('10102008','','Circular Quay' 'YOUR_API_KEY')
Errors
No leave event with wrong stop ID or not matching route.
{'stop_id': 'n/a', 'route': 'n/a', 'due': 'n/a', 'delay': 'n/a', 'real_time': 'n/a', destination: 'n/a'}
Metadata
Release files for PyTransportNSW 0.1.1
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 | |
|---|---|---|---|---|
| PyTransportNSW-0.1.1.tar.gz | 3.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyTransportNSW-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.6 kB
Release files / PyTransportNSW-0.1.1.tar.gz
| Download URL | PyTransportNSW-0.1.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c381d0e20c6522b1a1d9d4b4fc56487df7f8b2b08261ac224485d51ce5a35302
|
|
BLAKE2b-256 checksum How to use checksums |
f5eae978a5662e2a2db76427258cbb2c089b934d08ddfdca07e4819c20a302f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Release files / PyTransportNSW-0.1.1-py3-none-any.whl
| Download URL | PyTransportNSW-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82ea8a24117a7b6698079d2320eb6b6c477fc1afcc5af657ba43d837a9d10eee
|
|
BLAKE2b-256 checksum How to use checksums |
e94d79916e6cd02394ec0d0cc4f87129df7c4ae4cd8aab1f41544ce9b6f2ff74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
|
Security for PyTransportNSW 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.