You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The One Bus Away Python library provides convenient access to the One Bus Away REST API from any Python 3.7+
5
+
The Open Transit Python library provides convenient access to the Open Transit REST API from any Python 3.7+
6
6
application. The library includes type definitions for all request params and response fields,
7
7
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
8
8
9
9
It is generated with [Stainless](https://www.stainlessapi.com/).
10
10
11
11
## Documentation
12
12
13
-
The REST API documentation can be found [on developer.onebusaway.org](https://developer.onebusaway.org). The full API of this library can be found in [api.md](api.md).
13
+
The REST API documentation can be found [on docs.open-transit.com](https://docs.open-transit.com). The full API of this library can be found in [api.md](api.md).
@@ -80,27 +80,27 @@ Typed requests and responses provide autocomplete and documentation within your
80
80
81
81
## Handling errors
82
82
83
-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `onebusaway.APIConnectionError` is raised.
83
+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `open_transit.APIConnectionError` is raised.
84
84
85
85
When the API returns a non-success status code (that is, 4xx or 5xx
86
-
response), a subclass of `onebusaway.APIStatusError` is raised, containing `status_code` and `response` properties.
86
+
response), a subclass of `open_transit.APIStatusError` is raised, containing `status_code` and `response` properties.
87
87
88
-
All errors inherit from `onebusaway.APIError`.
88
+
All errors inherit from `open_transit.APIError`.
89
89
90
90
```python
91
-
importonebusaway
92
-
fromonebusawayimportOneBusAway
91
+
importopen_transit
92
+
fromopen_transitimportOpenTransit
93
93
94
-
client =OneBusAway()
94
+
client =OpenTransit()
95
95
96
96
try:
97
-
client.agencies_with_coverage.retrieve()
98
-
exceptonebusaway.APIConnectionError as e:
97
+
client.where.config.retrieve()
98
+
exceptopen_transit.APIConnectionError as e:
99
99
print("The server could not be reached")
100
100
print(e.__cause__) # an underlying Exception, likely raised within httpx.
101
-
exceptonebusaway.RateLimitError as e:
101
+
exceptopen_transit.RateLimitError as e:
102
102
print("A 429 status code was received; we should back off a bit.")
103
-
exceptonebusaway.APIStatusError as e:
103
+
exceptopen_transit.APIStatusError as e:
104
104
print("Another non-200-range status code was received")
105
105
print(e.status_code)
106
106
print(e.response)
@@ -128,16 +128,16 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
128
128
You can use the `max_retries` option to configure or disable retry settings:
agencies_with_coverage= response.parse() # get the object that `agencies_with_coverage.retrieve()` would have returned
206
-
print(agencies_with_coverage.code)
205
+
config= response.parse() # get the object that `where.config.retrieve()` would have returned
206
+
print(config.code)
207
207
```
208
208
209
-
These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/onebusaway/_response.py) object.
209
+
These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/open_transit/_response.py) object.
210
210
211
-
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/onebusaway/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
211
+
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/open_transit/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
212
212
213
213
#### `.with_streaming_response`
214
214
@@ -217,7 +217,7 @@ The above interface eagerly reads the full response body when you make the reque
217
217
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
218
218
219
219
```python
220
-
with client.agencies_with_coverage.with_streaming_response.retrieve() as response:
220
+
with client.where.config.with_streaming_response.retrieve() as response:
221
221
print(response.headers.get("X-My-Header"))
222
222
223
223
for line in response.iter_lines():
@@ -270,10 +270,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
0 commit comments