PyTransportNSWv2 0.3.4__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/LICENSE +0 -0
- PyTransportNSWv2-0.5.0/PKG-INFO +77 -0
- PyTransportNSWv2-0.5.0/PyTransportNSWv2.egg-info/PKG-INFO +77 -0
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/PyTransportNSWv2.egg-info/SOURCES.txt +2 -2
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/PyTransportNSWv2.egg-info/requires.txt +0 -1
- PyTransportNSWv2-0.5.0/PyTransportNSWv2.egg-info/top_level.txt +1 -0
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/README.md +4 -16
- pytransportnswv2-0.3.4/TransportNSW/TransportNSW.py → PyTransportNSWv2-0.5.0/TransportNSWv2/TransportNSWv2.py +4 -14
- PyTransportNSWv2-0.5.0/TransportNSWv2/__init__.py +2 -0
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/setup.py +1 -2
- pytransportnswv2-0.3.4/PKG-INFO +0 -90
- pytransportnswv2-0.3.4/PyTransportNSWv2.egg-info/PKG-INFO +0 -90
- pytransportnswv2-0.3.4/PyTransportNSWv2.egg-info/top_level.txt +0 -1
- pytransportnswv2-0.3.4/TransportNSW/__init__.py +0 -2
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/PyTransportNSWv2.egg-info/dependency_links.txt +0 -0
- {pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/setup.cfg +0 -0
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: PyTransportNSWv2
|
3
|
+
Version: 0.5.0
|
4
|
+
Summary: Get detailed per-trip transport information from TransportNSW
|
5
|
+
Home-page: https://github.com/andystewart999/TransportNSW
|
6
|
+
Author: andystewart999
|
7
|
+
License: UNKNOWN
|
8
|
+
Description: # TransportNSWv2
|
9
|
+
Python lib to access Transport NSW information.
|
10
|
+
|
11
|
+
## How to Use
|
12
|
+
|
13
|
+
### Get an API Key
|
14
|
+
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:
|
15
|
+
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
|
16
|
+
|
17
|
+
### Get the stop IDs
|
18
|
+
The function needs the stop IDs for the source and destination, and optionally how many minutes from now the departure should be, and if you want to filter trips by a specific transport type. 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.
|
19
|
+
|
20
|
+
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.
|
21
|
+
|
22
|
+
### API Documentation
|
23
|
+
The source API details can be found here: https://opendata.transport.nsw.gov.au/sites/default/files/2023-08/Trip%20Planner%20API%20manual-opendataproduction%20v3.2.pdf
|
24
|
+
|
25
|
+
### Parameters
|
26
|
+
```python
|
27
|
+
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
28
|
+
```
|
29
|
+
|
30
|
+
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
31
|
+
|
32
|
+
### Sample Code
|
33
|
+
|
34
|
+
The following example will return the next trip that starts from a bus stop in St. Ives (207537) five minutes from now, to Central Station's general stop ID (10101100):
|
35
|
+
|
36
|
+
**Code:**
|
37
|
+
```python
|
38
|
+
from TransportNSWv2 import TransportNSWv2
|
39
|
+
tnsw = TransportNSWv2()
|
40
|
+
journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
|
41
|
+
print(journey)
|
42
|
+
```
|
43
|
+
**Result:**
|
44
|
+
```python
|
45
|
+
{"due": 3, "origin_stop_id": "207537", "origin_name": "Mona Vale Rd at Shinfield Ave, St Ives", "departure_time": "2024-05-20T21:59:48Z", "destination_stop_id": "2000338", "destination_name": "Central Station, Platform 18, Sydney", "arrival_time": "2024-05-20T22:47:36Z", "origin_transport_type": "Bus", "origin_transport_name": "Sydney Buses Network", "origin_line_name": "195", "origin_line_name_short": "195", "changes": 1, "occupancy": "MANY_SEATS", "real_time_trip_id": "2096551", "latitude": -33.72665786743164, "longitude": 151.16305541992188}
|
46
|
+
```
|
47
|
+
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with it.
|
48
|
+
|
49
|
+
* due: the time (in minutes) before the journey starts
|
50
|
+
* origin_stop_id: the specific departure stop id
|
51
|
+
* origin_name: the name of the departure location
|
52
|
+
* departure_time: the departure time, in UTC
|
53
|
+
* destination_stop_id: the specific destination stop id
|
54
|
+
* destination_name: the name of the destination location
|
55
|
+
* arrival_time: the planned arrival time at the origin, in UTC
|
56
|
+
* origin_transport_type: the type of transport, eg train, bus, ferry etc
|
57
|
+
* origin_transport_name: the full name of the transport provider
|
58
|
+
* origin_line_name & origin_line_name_short: the full and short names of the journey
|
59
|
+
* changes: how many transport changes are needed on the journey
|
60
|
+
* occupancy: how full the vehicle is, if available
|
61
|
+
* real_time_trip_id: the unique TransportNSW id for that specific journey, if available
|
62
|
+
* latitude & longitude: The location of the vehicle, if available
|
63
|
+
|
64
|
+
Please note that the origin and destination detail is just that - information about the first and last stops on the journey at the time the request was made. We don't return any intermediate steps, transport change types etc other than the total number of changes - the assumption is that you'll know the details of your specified trip, you just want to know when the next departure is. If you need much more detailed information then I recommend that you use the full Transport NSW trip planner website or application.
|
65
|
+
Also note that the 'transport_type' filter, if present, only makes sure that at least one leg of the journey includes that transport type.
|
66
|
+
|
67
|
+
## Thank you
|
68
|
+
Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
|
69
|
+
https://github.com/Dav0815/TransportNSW
|
70
|
+
|
71
|
+
Platform: UNKNOWN
|
72
|
+
Classifier: Programming Language :: Python :: 3
|
73
|
+
Classifier: License :: OSI Approved :: MIT License
|
74
|
+
Classifier: Operating System :: OS Independent
|
75
|
+
Classifier: Intended Audience :: Developers
|
76
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
77
|
+
Description-Content-Type: text/markdown
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: PyTransportNSWv2
|
3
|
+
Version: 0.5.0
|
4
|
+
Summary: Get detailed per-trip transport information from TransportNSW
|
5
|
+
Home-page: https://github.com/andystewart999/TransportNSW
|
6
|
+
Author: andystewart999
|
7
|
+
License: UNKNOWN
|
8
|
+
Description: # TransportNSWv2
|
9
|
+
Python lib to access Transport NSW information.
|
10
|
+
|
11
|
+
## How to Use
|
12
|
+
|
13
|
+
### Get an API Key
|
14
|
+
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:
|
15
|
+
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
|
16
|
+
|
17
|
+
### Get the stop IDs
|
18
|
+
The function needs the stop IDs for the source and destination, and optionally how many minutes from now the departure should be, and if you want to filter trips by a specific transport type. 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.
|
19
|
+
|
20
|
+
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.
|
21
|
+
|
22
|
+
### API Documentation
|
23
|
+
The source API details can be found here: https://opendata.transport.nsw.gov.au/sites/default/files/2023-08/Trip%20Planner%20API%20manual-opendataproduction%20v3.2.pdf
|
24
|
+
|
25
|
+
### Parameters
|
26
|
+
```python
|
27
|
+
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
28
|
+
```
|
29
|
+
|
30
|
+
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
31
|
+
|
32
|
+
### Sample Code
|
33
|
+
|
34
|
+
The following example will return the next trip that starts from a bus stop in St. Ives (207537) five minutes from now, to Central Station's general stop ID (10101100):
|
35
|
+
|
36
|
+
**Code:**
|
37
|
+
```python
|
38
|
+
from TransportNSWv2 import TransportNSWv2
|
39
|
+
tnsw = TransportNSWv2()
|
40
|
+
journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
|
41
|
+
print(journey)
|
42
|
+
```
|
43
|
+
**Result:**
|
44
|
+
```python
|
45
|
+
{"due": 3, "origin_stop_id": "207537", "origin_name": "Mona Vale Rd at Shinfield Ave, St Ives", "departure_time": "2024-05-20T21:59:48Z", "destination_stop_id": "2000338", "destination_name": "Central Station, Platform 18, Sydney", "arrival_time": "2024-05-20T22:47:36Z", "origin_transport_type": "Bus", "origin_transport_name": "Sydney Buses Network", "origin_line_name": "195", "origin_line_name_short": "195", "changes": 1, "occupancy": "MANY_SEATS", "real_time_trip_id": "2096551", "latitude": -33.72665786743164, "longitude": 151.16305541992188}
|
46
|
+
```
|
47
|
+
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with it.
|
48
|
+
|
49
|
+
* due: the time (in minutes) before the journey starts
|
50
|
+
* origin_stop_id: the specific departure stop id
|
51
|
+
* origin_name: the name of the departure location
|
52
|
+
* departure_time: the departure time, in UTC
|
53
|
+
* destination_stop_id: the specific destination stop id
|
54
|
+
* destination_name: the name of the destination location
|
55
|
+
* arrival_time: the planned arrival time at the origin, in UTC
|
56
|
+
* origin_transport_type: the type of transport, eg train, bus, ferry etc
|
57
|
+
* origin_transport_name: the full name of the transport provider
|
58
|
+
* origin_line_name & origin_line_name_short: the full and short names of the journey
|
59
|
+
* changes: how many transport changes are needed on the journey
|
60
|
+
* occupancy: how full the vehicle is, if available
|
61
|
+
* real_time_trip_id: the unique TransportNSW id for that specific journey, if available
|
62
|
+
* latitude & longitude: The location of the vehicle, if available
|
63
|
+
|
64
|
+
Please note that the origin and destination detail is just that - information about the first and last stops on the journey at the time the request was made. We don't return any intermediate steps, transport change types etc other than the total number of changes - the assumption is that you'll know the details of your specified trip, you just want to know when the next departure is. If you need much more detailed information then I recommend that you use the full Transport NSW trip planner website or application.
|
65
|
+
Also note that the 'transport_type' filter, if present, only makes sure that at least one leg of the journey includes that transport type.
|
66
|
+
|
67
|
+
## Thank you
|
68
|
+
Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
|
69
|
+
https://github.com/Dav0815/TransportNSW
|
70
|
+
|
71
|
+
Platform: UNKNOWN
|
72
|
+
Classifier: Programming Language :: Python :: 3
|
73
|
+
Classifier: License :: OSI Approved :: MIT License
|
74
|
+
Classifier: Operating System :: OS Independent
|
75
|
+
Classifier: Intended Audience :: Developers
|
76
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
77
|
+
Description-Content-Type: text/markdown
|
@@ -6,5 +6,5 @@ PyTransportNSWv2.egg-info/SOURCES.txt
|
|
6
6
|
PyTransportNSWv2.egg-info/dependency_links.txt
|
7
7
|
PyTransportNSWv2.egg-info/requires.txt
|
8
8
|
PyTransportNSWv2.egg-info/top_level.txt
|
9
|
-
|
10
|
-
|
9
|
+
TransportNSWv2/TransportNSWv2.py
|
10
|
+
TransportNSWv2/__init__.py
|
@@ -0,0 +1 @@
|
|
1
|
+
TransportNSWv2
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# TransportNSWv2
|
2
2
|
Python lib to access Transport NSW information.
|
3
3
|
|
4
4
|
## How to Use
|
@@ -19,20 +19,8 @@ The source API details can be found here: https://opendata.transport.nsw.gov.au/
|
|
19
19
|
```python
|
20
20
|
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
21
21
|
```
|
22
|
-
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
23
22
|
|
24
|
-
|
25
|
-
```
|
26
|
-
1: Train
|
27
|
-
4: Light rail
|
28
|
-
5: Bus
|
29
|
-
7: Coach
|
30
|
-
9: Ferry
|
31
|
-
11: School bus
|
32
|
-
99: Walk
|
33
|
-
100: Walk
|
34
|
-
107: Cycle
|
35
|
-
```
|
23
|
+
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
36
24
|
|
37
25
|
### Sample Code
|
38
26
|
|
@@ -40,8 +28,8 @@ The following example will return the next trip that starts from a bus stop in S
|
|
40
28
|
|
41
29
|
**Code:**
|
42
30
|
```python
|
43
|
-
from
|
44
|
-
tnsw =
|
31
|
+
from TransportNSWv2 import TransportNSWv2
|
32
|
+
tnsw = TransportNSWv2()
|
45
33
|
journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
|
46
34
|
print(journey)
|
47
35
|
```
|
@@ -34,7 +34,7 @@ ATTR_LONGITUDE = 'longitude'
|
|
34
34
|
|
35
35
|
logger = logging.getLogger(__name__)
|
36
36
|
|
37
|
-
class
|
37
|
+
class TransportNSWv2(object):
|
38
38
|
"""The Class for handling the data retrieval."""
|
39
39
|
|
40
40
|
# The application requires an API key. You can register for
|
@@ -157,7 +157,7 @@ class TransportNSW(object):
|
|
157
157
|
origin_name = origin['name']
|
158
158
|
origin_departure_time = origin['departureTimeEstimated']
|
159
159
|
|
160
|
-
|
160
|
+
# How long until it leaves?
|
161
161
|
due = self.get_due(datetime.strptime(origin_departure_time, fmt))
|
162
162
|
|
163
163
|
# Destination info
|
@@ -276,12 +276,7 @@ class TransportNSW(object):
|
|
276
276
|
for leg in range (0, leg_count, 1):
|
277
277
|
leg_class = legs[leg]['transportation']['product']['class']
|
278
278
|
|
279
|
-
|
280
|
-
if legtype != 0 and leg_class == legtype:
|
281
|
-
return leg
|
282
|
-
|
283
|
-
# We don't have a filter, and this is the first non-walk/cycle leg so return it
|
284
|
-
if legtype == 0 and leg_class < 99:
|
279
|
+
if leg_class == legtype or legtype == 0:
|
285
280
|
return leg
|
286
281
|
|
287
282
|
# Hmm, we didn't find one
|
@@ -294,12 +289,7 @@ class TransportNSW(object):
|
|
294
289
|
for leg in range (leg_count - 1, -1, -1):
|
295
290
|
leg_class = legs[leg]['transportation']['product']['class']
|
296
291
|
|
297
|
-
|
298
|
-
if legtype != 0 and leg_class == legtype:
|
299
|
-
return leg
|
300
|
-
|
301
|
-
# We don't have a filter, and this is the first non-walk/cycle leg so return it
|
302
|
-
if legtype == 0 and leg_class < 99:
|
292
|
+
if leg_class == legtype or legtype == 0:
|
303
293
|
return leg
|
304
294
|
|
305
295
|
# Hmm, we didn't find one
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name="PyTransportNSWv2",
|
8
|
-
version="0.
|
8
|
+
version="0.5.0",
|
9
9
|
author="andystewart999",
|
10
10
|
description="Get detailed per-trip transport information from TransportNSW",
|
11
11
|
long_description=long_description,
|
@@ -14,7 +14,6 @@ setuptools.setup(
|
|
14
14
|
packages=setuptools.find_packages(),
|
15
15
|
install_requires=[
|
16
16
|
'gtfs-realtime-bindings',
|
17
|
-
'requests'
|
18
17
|
],
|
19
18
|
classifiers=[
|
20
19
|
"Programming Language :: Python :: 3",
|
pytransportnswv2-0.3.4/PKG-INFO
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: PyTransportNSWv2
|
3
|
-
Version: 0.3.4
|
4
|
-
Summary: Get detailed per-trip transport information from TransportNSW
|
5
|
-
Home-page: https://github.com/andystewart999/TransportNSW
|
6
|
-
Author: andystewart999
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
9
|
-
Classifier: Operating System :: OS Independent
|
10
|
-
Classifier: Intended Audience :: Developers
|
11
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
12
|
-
Description-Content-Type: text/markdown
|
13
|
-
License-File: LICENSE
|
14
|
-
Requires-Dist: gtfs-realtime-bindings
|
15
|
-
Requires-Dist: requests
|
16
|
-
|
17
|
-
# TransportNSW
|
18
|
-
Python lib to access Transport NSW information.
|
19
|
-
|
20
|
-
## How to Use
|
21
|
-
|
22
|
-
### Get an API Key
|
23
|
-
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:
|
24
|
-
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
|
25
|
-
|
26
|
-
### Get the stop IDs
|
27
|
-
The function needs the stop IDs for the source and destination, and optionally how many minutes from now the departure should be, and if you want to filter trips by a specific transport type. 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.
|
28
|
-
|
29
|
-
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.
|
30
|
-
|
31
|
-
### API Documentation
|
32
|
-
The source API details can be found here: https://opendata.transport.nsw.gov.au/sites/default/files/2023-08/Trip%20Planner%20API%20manual-opendataproduction%20v3.2.pdf
|
33
|
-
|
34
|
-
### Parameters
|
35
|
-
```python
|
36
|
-
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
37
|
-
```
|
38
|
-
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
39
|
-
|
40
|
-
### transport_type filters
|
41
|
-
```
|
42
|
-
1: Train
|
43
|
-
4: Light rail
|
44
|
-
5: Bus
|
45
|
-
7: Coach
|
46
|
-
9: Ferry
|
47
|
-
11: School bus
|
48
|
-
99: Walk
|
49
|
-
100: Walk
|
50
|
-
107: Cycle
|
51
|
-
```
|
52
|
-
|
53
|
-
### Sample Code
|
54
|
-
|
55
|
-
The following example will return the next trip that starts from a bus stop in St. Ives (207537) five minutes from now, to Central Station's general stop ID (10101100):
|
56
|
-
|
57
|
-
**Code:**
|
58
|
-
```python
|
59
|
-
from TransportNSW import TransportNSW
|
60
|
-
tnsw = TransportNSW()
|
61
|
-
journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
|
62
|
-
print(journey)
|
63
|
-
```
|
64
|
-
**Result:**
|
65
|
-
```python
|
66
|
-
{"due": 3, "origin_stop_id": "207537", "origin_name": "Mona Vale Rd at Shinfield Ave, St Ives", "departure_time": "2024-05-20T21:59:48Z", "destination_stop_id": "2000338", "destination_name": "Central Station, Platform 18, Sydney", "arrival_time": "2024-05-20T22:47:36Z", "origin_transport_type": "Bus", "origin_transport_name": "Sydney Buses Network", "origin_line_name": "195", "origin_line_name_short": "195", "changes": 1, "occupancy": "MANY_SEATS", "real_time_trip_id": "2096551", "latitude": -33.72665786743164, "longitude": 151.16305541992188}
|
67
|
-
```
|
68
|
-
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with it.
|
69
|
-
|
70
|
-
* due: the time (in minutes) before the journey starts
|
71
|
-
* origin_stop_id: the specific departure stop id
|
72
|
-
* origin_name: the name of the departure location
|
73
|
-
* departure_time: the departure time, in UTC
|
74
|
-
* destination_stop_id: the specific destination stop id
|
75
|
-
* destination_name: the name of the destination location
|
76
|
-
* arrival_time: the planned arrival time at the origin, in UTC
|
77
|
-
* origin_transport_type: the type of transport, eg train, bus, ferry etc
|
78
|
-
* origin_transport_name: the full name of the transport provider
|
79
|
-
* origin_line_name & origin_line_name_short: the full and short names of the journey
|
80
|
-
* changes: how many transport changes are needed on the journey
|
81
|
-
* occupancy: how full the vehicle is, if available
|
82
|
-
* real_time_trip_id: the unique TransportNSW id for that specific journey, if available
|
83
|
-
* latitude & longitude: The location of the vehicle, if available
|
84
|
-
|
85
|
-
Please note that the origin and destination detail is just that - information about the first and last stops on the journey at the time the request was made. We don't return any intermediate steps, transport change types etc other than the total number of changes - the assumption is that you'll know the details of your specified trip, you just want to know when the next departure is. If you need much more detailed information then I recommend that you use the full Transport NSW trip planner website or application.
|
86
|
-
Also note that the 'transport_type' filter, if present, only makes sure that at least one leg of the journey includes that transport type.
|
87
|
-
|
88
|
-
## Thank you
|
89
|
-
Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
|
90
|
-
https://github.com/Dav0815/TransportNSW
|
@@ -1,90 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: PyTransportNSWv2
|
3
|
-
Version: 0.3.4
|
4
|
-
Summary: Get detailed per-trip transport information from TransportNSW
|
5
|
-
Home-page: https://github.com/andystewart999/TransportNSW
|
6
|
-
Author: andystewart999
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
9
|
-
Classifier: Operating System :: OS Independent
|
10
|
-
Classifier: Intended Audience :: Developers
|
11
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
12
|
-
Description-Content-Type: text/markdown
|
13
|
-
License-File: LICENSE
|
14
|
-
Requires-Dist: gtfs-realtime-bindings
|
15
|
-
Requires-Dist: requests
|
16
|
-
|
17
|
-
# TransportNSW
|
18
|
-
Python lib to access Transport NSW information.
|
19
|
-
|
20
|
-
## How to Use
|
21
|
-
|
22
|
-
### Get an API Key
|
23
|
-
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:
|
24
|
-
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
|
25
|
-
|
26
|
-
### Get the stop IDs
|
27
|
-
The function needs the stop IDs for the source and destination, and optionally how many minutes from now the departure should be, and if you want to filter trips by a specific transport type. 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.
|
28
|
-
|
29
|
-
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.
|
30
|
-
|
31
|
-
### API Documentation
|
32
|
-
The source API details can be found here: https://opendata.transport.nsw.gov.au/sites/default/files/2023-08/Trip%20Planner%20API%20manual-opendataproduction%20v3.2.pdf
|
33
|
-
|
34
|
-
### Parameters
|
35
|
-
```python
|
36
|
-
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
37
|
-
```
|
38
|
-
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
39
|
-
|
40
|
-
### transport_type filters
|
41
|
-
```
|
42
|
-
1: Train
|
43
|
-
4: Light rail
|
44
|
-
5: Bus
|
45
|
-
7: Coach
|
46
|
-
9: Ferry
|
47
|
-
11: School bus
|
48
|
-
99: Walk
|
49
|
-
100: Walk
|
50
|
-
107: Cycle
|
51
|
-
```
|
52
|
-
|
53
|
-
### Sample Code
|
54
|
-
|
55
|
-
The following example will return the next trip that starts from a bus stop in St. Ives (207537) five minutes from now, to Central Station's general stop ID (10101100):
|
56
|
-
|
57
|
-
**Code:**
|
58
|
-
```python
|
59
|
-
from TransportNSW import TransportNSW
|
60
|
-
tnsw = TransportNSW()
|
61
|
-
journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
|
62
|
-
print(journey)
|
63
|
-
```
|
64
|
-
**Result:**
|
65
|
-
```python
|
66
|
-
{"due": 3, "origin_stop_id": "207537", "origin_name": "Mona Vale Rd at Shinfield Ave, St Ives", "departure_time": "2024-05-20T21:59:48Z", "destination_stop_id": "2000338", "destination_name": "Central Station, Platform 18, Sydney", "arrival_time": "2024-05-20T22:47:36Z", "origin_transport_type": "Bus", "origin_transport_name": "Sydney Buses Network", "origin_line_name": "195", "origin_line_name_short": "195", "changes": 1, "occupancy": "MANY_SEATS", "real_time_trip_id": "2096551", "latitude": -33.72665786743164, "longitude": 151.16305541992188}
|
67
|
-
```
|
68
|
-
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with it.
|
69
|
-
|
70
|
-
* due: the time (in minutes) before the journey starts
|
71
|
-
* origin_stop_id: the specific departure stop id
|
72
|
-
* origin_name: the name of the departure location
|
73
|
-
* departure_time: the departure time, in UTC
|
74
|
-
* destination_stop_id: the specific destination stop id
|
75
|
-
* destination_name: the name of the destination location
|
76
|
-
* arrival_time: the planned arrival time at the origin, in UTC
|
77
|
-
* origin_transport_type: the type of transport, eg train, bus, ferry etc
|
78
|
-
* origin_transport_name: the full name of the transport provider
|
79
|
-
* origin_line_name & origin_line_name_short: the full and short names of the journey
|
80
|
-
* changes: how many transport changes are needed on the journey
|
81
|
-
* occupancy: how full the vehicle is, if available
|
82
|
-
* real_time_trip_id: the unique TransportNSW id for that specific journey, if available
|
83
|
-
* latitude & longitude: The location of the vehicle, if available
|
84
|
-
|
85
|
-
Please note that the origin and destination detail is just that - information about the first and last stops on the journey at the time the request was made. We don't return any intermediate steps, transport change types etc other than the total number of changes - the assumption is that you'll know the details of your specified trip, you just want to know when the next departure is. If you need much more detailed information then I recommend that you use the full Transport NSW trip planner website or application.
|
86
|
-
Also note that the 'transport_type' filter, if present, only makes sure that at least one leg of the journey includes that transport type.
|
87
|
-
|
88
|
-
## Thank you
|
89
|
-
Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
|
90
|
-
https://github.com/Dav0815/TransportNSW
|
@@ -1 +0,0 @@
|
|
1
|
-
TransportNSW
|
{pytransportnswv2-0.3.4 → PyTransportNSWv2-0.5.0}/PyTransportNSWv2.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|