Get detailed per-trip transport information from TransportNSW
Reason this release was yanked:
There's a typo in __init__.py that I haven't fixed yet.
Project description
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. You need to register an application that needs both the Trip Planner and Realtime Vehicle Positions APIs
Get the stop IDs
The library needs the stop ID for the source and destination, and optionally how many minutes from now the departure should be. The easiest way to get the stop ID is via https://transportnsw.info/stops#/. It provides the option to search for either a location or a specific platform, bus stop or ferry wharf. Regardless of if you specify a general location for the origin or destination, the return information shows the stop_id for the actual arrival and destination platform, bus stop or ferry wharf.
If it's available, the general occupancy level and the latitude and longitude of the selected journey's vehicle (train, bus, etc) will be returned.
API Documentation
The source API details can be found here: https://opendata.transport.nsw.gov.au/node/601/exploreapi
Parameters
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0])
Sample Code
The following example will return the next trip from Gordon Station to Pymble Station, without specifying a platform.
Code:
from TransportNSW import TransportNSW
tnsw = TransportNSW()
journey = tnsw.get_trip('10101121', '10101123', 'YOUR_API_KEY')
print(journey)
Result:
{'due': 5, 'origin_stop_id': '207263', 'origin_name': 'Gordon Station', 'origin_detail': 'Platform 3', 'departure_time': '2020-06-14T10:21:30Z', 'destination_stop_id': '2073162', 'destination_name': 'Pymble Station', 'destination_detail': 'Platform 2', 'arrival_time': '2020-06-14T10:23:30Z', 'transport_type': 'Train', 'transport_name': 'Sydney Trains Network', 'line_name': 'T1 North Shore & Western Line', 'line_name_short': 'T1', 'occupancy': 'UNKNOWN', 'real_time_trip_id': '104P.1379.110.128.T.8.61720413', 'latitude': -33.76505661010742, 'longitude': 151.1614227294922}
- due: the time (in minutes) before the vehicle arrives
- origin_stop_id: the specific departure stop id
- origin_name: the name of the general departure location
- origin_detail: the specific departure location
- arrival_time: the arrival time at the origin
- transport_type: the type of transport, eg train, bus, ferry etc
- transport_name: the full name of transport providere
- line_name & line_name_short: the full and short names of the journey
- occupancy: how full the vehicle is
- real_time_trip_id: the unique TransportNSW id for that specific journey
- latitude & longitude: The location of the vehicle, if available
To do:
- Add an option to filter by specific transport type, useful if the general departure and arrival ids are being used
- Add an option to show brief vs verbose information
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PyTransportNSWv2-0.2.0.tar.gz
.
File metadata
- Download URL: PyTransportNSWv2-0.2.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a241d9095bef02fa09d4667f2addee4775dae388b1a6450b51098577e0d8db4 |
|
MD5 | 039ddf385a0a81727f29341ec2b93180 |
|
BLAKE2b-256 | fd2e3e63f249778613b112d221fcd31b1e7785156fecc826c346752483dfbb9f |
File details
Details for the file PyTransportNSWv2-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: PyTransportNSWv2-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a48a3f7614ac43efd64bd35b5366fa652e7c2169fdfe82dd09a3e840db6cfce7 |
|
MD5 | 5fdf570e3d7722b2b5a509e5197d81b5 |
|
BLAKE2b-256 | 37d1621b87daa372ff585eba7e138260757a3ac3c42aad1ac52ff56f1acee6bb |