PyTransportNSWv2 0.4.0__tar.gz → 0.5.1__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.
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyTransportNSWv2
3
+ Version: 0.5.1
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.1
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
- TransportNSW/TransportNSW.py
10
- TransportNSW/__init__.py
9
+ TransportNSWv2/TransportNSWv2.py
10
+ TransportNSWv2/__init__.py
@@ -1,2 +1 @@
1
1
  gtfs-realtime-bindings
2
- requests
@@ -0,0 +1 @@
1
+ TransportNSWv2
@@ -1,4 +1,4 @@
1
- # TransportNSW
1
+ # TransportNSWv2
2
2
  Python lib to access Transport NSW information.
3
3
 
4
4
  ## How to Use
@@ -17,66 +17,25 @@ The source API details can be found here: https://opendata.transport.nsw.gov.au/
17
17
 
18
18
  ### Parameters
19
19
  ```python
20
- .get_trip(origin_stop_id, destination_stop_id, api_key, [journey_wait_time = 0], [transport_type = 0], [strict_transport_type = False], [raw_output = False], [journeys_to_return = 1])
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
-
24
- ### transport_type filters
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
- ```
36
- If you call the function with a `transport_type` filter and set `strict_transport_type` to `True`, only journeys whose **first** leg matches the desired filter will be considered. Otherwise the filter includes a journey if **any** of the legs includes the desired travel type.
37
22
 
38
- `raw_output` simply returns the entire API response string as JSON, without making any changes to it.
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.
39
24
 
40
25
  ### Sample Code
41
26
 
42
- The following example will return the next trip that starts from Pymble Station (207310) five minutes from now, to Gordon Station (207210). Note that specific platforms, such as Gordon Station, Platform 3 (207263) haven't been specified so any platform combination will be accepted:
27
+ 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):
43
28
 
44
29
  **Code:**
45
30
  ```python
46
- from TransportNSW import TransportNSW
47
- tnsw = TransportNSW()
31
+ from TransportNSWv2 import TransportNSWv2
32
+ tnsw = TransportNSWv2()
48
33
  journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
49
34
  print(journey)
50
35
  ```
51
36
  **Result:**
52
-
53
- Unless `raw_output` is `True`, the return output always returns an array of journeys, even if `journeys_to_return` is 1. The journey array is preceded by how many journeys were requested, and how many were actually returned that contained usable data:
54
-
55
- ```json
56
- {
57
- "journeys_to_return": 1,
58
- "journeys_with_data": 1,
59
- "journeys": [
60
- {
61
- "due": 6,
62
- "origin_stop_id": "2073161",
63
- "origin_name": "Pymble Station, Platform 1, Pymble",
64
- "departure_time": "2024-05-28T22:40:24Z",
65
- "destination_stop_id": "207261",
66
- "destination_name": "Gordon Station, Platform 1, Gordon",
67
- "arrival_time": "2024-05-28T22:42:30Z",
68
- "origin_transport_type": "Train",
69
- "origin_transport_name": "Sydney Trains Network",
70
- "origin_line_name": "T1 North Shore & Western Line",
71
- "origin_line_name_short": "T1",
72
- "changes": 0,
73
- "occupancy": "UNKNOWN",
74
- "real_time_trip_id": "161E.1378.133.60.A.8.80758268",
75
- "latitude": "n/a",
76
- "longitude": "n/a"
77
- }
78
- ]
79
- }
37
+ ```python
38
+ {"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}
80
39
  ```
81
40
  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.
82
41
 
@@ -96,6 +55,7 @@ Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single q
96
55
  * latitude & longitude: The location of the vehicle, if available
97
56
 
98
57
  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.
58
+ Also note that the 'transport_type' filter, if present, only makes sure that at least one leg of the journey includes that transport type.
99
59
 
100
60
  ## Thank you
101
61
  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!
@@ -34,7 +34,7 @@ ATTR_LONGITUDE = 'longitude'
34
34
 
35
35
  logger = logging.getLogger(__name__)
36
36
 
37
- class TransportNSW(object):
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
@@ -0,0 +1,2 @@
1
+ """Define module-level imports."""
2
+ from TransportNSWv2.TransportNSWv2 import TransportNSWv2
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="PyTransportNSWv2",
8
- version="0.4.0",
8
+ version="0.5.1",
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",
@@ -1,118 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyTransportNSWv2
3
- Version: 0.4.0
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, [journey_wait_time = 0], [transport_type = 0], [strict_transport_type = False], [raw_output = False], [journeys_to_return = 1])
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
- If you call the function with a `transport_type` filter and set `strict_transport_type` to `True`, only journeys whose **first** leg matches the desired filter will be considered. Otherwise the filter includes a journey if **any** of the legs includes the desired travel type.
53
-
54
- `raw_output` simply returns the entire API response string as JSON, without making any changes to it.
55
-
56
- ### Sample Code
57
-
58
- The following example will return the next trip that starts from Pymble Station (207310) five minutes from now, to Gordon Station (207210). Note that specific platforms, such as Gordon Station, Platform 3 (207263) haven't been specified so any platform combination will be accepted:
59
-
60
- **Code:**
61
- ```python
62
- from TransportNSW import TransportNSW
63
- tnsw = TransportNSW()
64
- journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
65
- print(journey)
66
- ```
67
- **Result:**
68
-
69
- Unless `raw_output` is `True`, the return output always returns an array of journeys, even if `journeys_to_return` is 1. The journey array is preceded by how many journeys were requested, and how many were actually returned that contained usable data:
70
-
71
- ```json
72
- {
73
- "journeys_to_return": 1,
74
- "journeys_with_data": 1,
75
- "journeys": [
76
- {
77
- "due": 6,
78
- "origin_stop_id": "2073161",
79
- "origin_name": "Pymble Station, Platform 1, Pymble",
80
- "departure_time": "2024-05-28T22:40:24Z",
81
- "destination_stop_id": "207261",
82
- "destination_name": "Gordon Station, Platform 1, Gordon",
83
- "arrival_time": "2024-05-28T22:42:30Z",
84
- "origin_transport_type": "Train",
85
- "origin_transport_name": "Sydney Trains Network",
86
- "origin_line_name": "T1 North Shore & Western Line",
87
- "origin_line_name_short": "T1",
88
- "changes": 0,
89
- "occupancy": "UNKNOWN",
90
- "real_time_trip_id": "161E.1378.133.60.A.8.80758268",
91
- "latitude": "n/a",
92
- "longitude": "n/a"
93
- }
94
- ]
95
- }
96
- ```
97
- 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.
98
-
99
- * due: the time (in minutes) before the journey starts
100
- * origin_stop_id: the specific departure stop id
101
- * origin_name: the name of the departure location
102
- * departure_time: the departure time, in UTC
103
- * destination_stop_id: the specific destination stop id
104
- * destination_name: the name of the destination location
105
- * arrival_time: the planned arrival time at the origin, in UTC
106
- * origin_transport_type: the type of transport, eg train, bus, ferry etc
107
- * origin_transport_name: the full name of the transport provider
108
- * origin_line_name & origin_line_name_short: the full and short names of the journey
109
- * changes: how many transport changes are needed on the journey
110
- * occupancy: how full the vehicle is, if available
111
- * real_time_trip_id: the unique TransportNSW id for that specific journey, if available
112
- * latitude & longitude: The location of the vehicle, if available
113
-
114
- 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.
115
-
116
- ## Thank you
117
- 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!
118
- https://github.com/Dav0815/TransportNSW
@@ -1,118 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: PyTransportNSWv2
3
- Version: 0.4.0
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, [journey_wait_time = 0], [transport_type = 0], [strict_transport_type = False], [raw_output = False], [journeys_to_return = 1])
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
- If you call the function with a `transport_type` filter and set `strict_transport_type` to `True`, only journeys whose **first** leg matches the desired filter will be considered. Otherwise the filter includes a journey if **any** of the legs includes the desired travel type.
53
-
54
- `raw_output` simply returns the entire API response string as JSON, without making any changes to it.
55
-
56
- ### Sample Code
57
-
58
- The following example will return the next trip that starts from Pymble Station (207310) five minutes from now, to Gordon Station (207210). Note that specific platforms, such as Gordon Station, Platform 3 (207263) haven't been specified so any platform combination will be accepted:
59
-
60
- **Code:**
61
- ```python
62
- from TransportNSW import TransportNSW
63
- tnsw = TransportNSW()
64
- journey = tnsw.get_trip('207537', '10101100', 'YOUR_API_KEY', 5)
65
- print(journey)
66
- ```
67
- **Result:**
68
-
69
- Unless `raw_output` is `True`, the return output always returns an array of journeys, even if `journeys_to_return` is 1. The journey array is preceded by how many journeys were requested, and how many were actually returned that contained usable data:
70
-
71
- ```json
72
- {
73
- "journeys_to_return": 1,
74
- "journeys_with_data": 1,
75
- "journeys": [
76
- {
77
- "due": 6,
78
- "origin_stop_id": "2073161",
79
- "origin_name": "Pymble Station, Platform 1, Pymble",
80
- "departure_time": "2024-05-28T22:40:24Z",
81
- "destination_stop_id": "207261",
82
- "destination_name": "Gordon Station, Platform 1, Gordon",
83
- "arrival_time": "2024-05-28T22:42:30Z",
84
- "origin_transport_type": "Train",
85
- "origin_transport_name": "Sydney Trains Network",
86
- "origin_line_name": "T1 North Shore & Western Line",
87
- "origin_line_name_short": "T1",
88
- "changes": 0,
89
- "occupancy": "UNKNOWN",
90
- "real_time_trip_id": "161E.1378.133.60.A.8.80758268",
91
- "latitude": "n/a",
92
- "longitude": "n/a"
93
- }
94
- ]
95
- }
96
- ```
97
- 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.
98
-
99
- * due: the time (in minutes) before the journey starts
100
- * origin_stop_id: the specific departure stop id
101
- * origin_name: the name of the departure location
102
- * departure_time: the departure time, in UTC
103
- * destination_stop_id: the specific destination stop id
104
- * destination_name: the name of the destination location
105
- * arrival_time: the planned arrival time at the origin, in UTC
106
- * origin_transport_type: the type of transport, eg train, bus, ferry etc
107
- * origin_transport_name: the full name of the transport provider
108
- * origin_line_name & origin_line_name_short: the full and short names of the journey
109
- * changes: how many transport changes are needed on the journey
110
- * occupancy: how full the vehicle is, if available
111
- * real_time_trip_id: the unique TransportNSW id for that specific journey, if available
112
- * latitude & longitude: The location of the vehicle, if available
113
-
114
- 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.
115
-
116
- ## Thank you
117
- 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!
118
- https://github.com/Dav0815/TransportNSW
@@ -1 +0,0 @@
1
- TransportNSW
@@ -1,2 +0,0 @@
1
- """Define module-level imports."""
2
- from TransportNSW.TransportNSW import TransportNSW