-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3beb328
commit 84da952
Showing
69 changed files
with
118 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# One Bus Away Python API library | ||
|
||
[![PyPI version](https://img.shields.io/pypi/v/open-transit.svg)](https://pypi.org/project/open-transit/) | ||
[![PyPI version](https://img.shields.io/pypi/v/onebusaway.svg)](https://pypi.org/project/onebusaway/) | ||
|
||
The One Bus Away Python library provides convenient access to the One Bus Away REST API from any Python 3.7+ | ||
application. The library includes type definitions for all request params and response fields, | ||
|
@@ -20,15 +20,15 @@ pip install git+ssh://[email protected]/stainless-sdks/open-transit-python.git | |
``` | ||
|
||
> [!NOTE] | ||
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre open-transit` | ||
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre onebusaway` | ||
## Usage | ||
|
||
The full API of this library can be found in [api.md](api.md). | ||
|
||
```python | ||
import os | ||
from open_transit import OneBusAway | ||
from onebusaway import OneBusAway | ||
|
||
client = OneBusAway( | ||
# This is the default and can be omitted | ||
|
@@ -50,7 +50,7 @@ Simply import `AsyncOneBusAway` instead of `OneBusAway` and use `await` with eac | |
```python | ||
import os | ||
import asyncio | ||
from open_transit import AsyncOneBusAway | ||
from onebusaway import AsyncOneBusAway | ||
|
||
client = AsyncOneBusAway( | ||
# This is the default and can be omitted | ||
|
@@ -78,27 +78,27 @@ Typed requests and responses provide autocomplete and documentation within your | |
|
||
## Handling errors | ||
|
||
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. | ||
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. | ||
|
||
When the API returns a non-success status code (that is, 4xx or 5xx | ||
response), a subclass of `open_transit.APIStatusError` is raised, containing `status_code` and `response` properties. | ||
response), a subclass of `onebusaway.APIStatusError` is raised, containing `status_code` and `response` properties. | ||
|
||
All errors inherit from `open_transit.APIError`. | ||
All errors inherit from `onebusaway.APIError`. | ||
|
||
```python | ||
import open_transit | ||
from open_transit import OneBusAway | ||
import onebusaway | ||
from onebusaway import OneBusAway | ||
|
||
client = OneBusAway() | ||
|
||
try: | ||
client.current_time.retrieve() | ||
except open_transit.APIConnectionError as e: | ||
except onebusaway.APIConnectionError as e: | ||
print("The server could not be reached") | ||
print(e.__cause__) # an underlying Exception, likely raised within httpx. | ||
except open_transit.RateLimitError as e: | ||
except onebusaway.RateLimitError as e: | ||
print("A 429 status code was received; we should back off a bit.") | ||
except open_transit.APIStatusError as e: | ||
except onebusaway.APIStatusError as e: | ||
print("Another non-200-range status code was received") | ||
print(e.status_code) | ||
print(e.response) | ||
|
@@ -126,7 +126,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ | |
You can use the `max_retries` option to configure or disable retry settings: | ||
|
||
```python | ||
from open_transit import OneBusAway | ||
from onebusaway import OneBusAway | ||
|
||
# Configure the default for all requests: | ||
client = OneBusAway( | ||
|
@@ -144,7 +144,7 @@ By default requests time out after 1 minute. You can configure this with a `time | |
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object: | ||
|
||
```python | ||
from open_transit import OneBusAway | ||
from onebusaway import OneBusAway | ||
|
||
# Configure the default for all requests: | ||
client = OneBusAway( | ||
|
@@ -194,7 +194,7 @@ if response.my_field is None: | |
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g., | ||
|
||
```py | ||
from open_transit import OneBusAway | ||
from onebusaway import OneBusAway | ||
|
||
client = OneBusAway() | ||
response = client.current_time.with_raw_response.retrieve() | ||
|
@@ -204,9 +204,9 @@ current_time = response.parse() # get the object that `current_time.retrieve()` | |
print(current_time) | ||
``` | ||
|
||
These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/open_transit/_response.py) object. | ||
These methods return an [`APIResponse`](https://github.com/stainless-sdks/open-transit-python/tree/main/src/onebusaway/_response.py) object. | ||
|
||
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. | ||
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. | ||
|
||
#### `.with_streaming_response` | ||
|
||
|
@@ -268,7 +268,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c | |
- Additional [advanced](https://www.python-httpx.org/advanced/#client-instances) functionality | ||
|
||
```python | ||
from open_transit import OneBusAway, DefaultHttpxClient | ||
from onebusaway import OneBusAway, DefaultHttpxClient | ||
|
||
client = OneBusAway( | ||
# Or use the `ONE_BUS_AWAY_BASE_URL` env var | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
# Shared Types | ||
|
||
```python | ||
from open_transit.types import ResponseWrapper | ||
from onebusaway.types import ResponseWrapper | ||
``` | ||
|
||
# AgenciesWithCoverage | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import AgenciesWithCoverageListResponse | ||
from onebusaway.types import AgenciesWithCoverageListResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/agencies-with-coverage.json">client.agencies_with_coverage.<a href="./src/open_transit/resources/agencies_with_coverage.py">list</a>() -> <a href="./src/open_transit/types/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code> | ||
- <code title="get /api/where/agencies-with-coverage.json">client.agencies_with_coverage.<a href="./src/onebusaway/resources/agencies_with_coverage.py">list</a>() -> <a href="./src/onebusaway/types/agencies_with_coverage_list_response.py">AgenciesWithCoverageListResponse</a></code> | ||
|
||
# Config | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import ConfigRetrieveResponse | ||
from onebusaway.types import ConfigRetrieveResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/config.json">client.config.<a href="./src/open_transit/resources/config.py">retrieve</a>() -> <a href="./src/open_transit/types/config_retrieve_response.py">ConfigRetrieveResponse</a></code> | ||
- <code title="get /api/where/config.json">client.config.<a href="./src/onebusaway/resources/config.py">retrieve</a>() -> <a href="./src/onebusaway/types/config_retrieve_response.py">ConfigRetrieveResponse</a></code> | ||
|
||
# CurrentTime | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import CurrentTimeRetrieveResponse | ||
from onebusaway.types import CurrentTimeRetrieveResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/current-time.json">client.current_time.<a href="./src/open_transit/resources/current_time.py">retrieve</a>() -> <a href="./src/open_transit/types/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code> | ||
- <code title="get /api/where/current-time.json">client.current_time.<a href="./src/onebusaway/resources/current_time.py">retrieve</a>() -> <a href="./src/onebusaway/types/current_time_retrieve_response.py">CurrentTimeRetrieveResponse</a></code> | ||
|
||
# StopsForLocation | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import StopsForLocationListResponse | ||
from onebusaway.types import StopsForLocationListResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/stops-for-location.json">client.stops_for_location.<a href="./src/open_transit/resources/stops_for_location.py">list</a>(\*\*<a href="src/open_transit/types/stops_for_location_list_params.py">params</a>) -> <a href="./src/open_transit/types/stops_for_location_list_response.py">StopsForLocationListResponse</a></code> | ||
- <code title="get /api/where/stops-for-location.json">client.stops_for_location.<a href="./src/onebusaway/resources/stops_for_location.py">list</a>(\*\*<a href="src/onebusaway/types/stops_for_location_list_params.py">params</a>) -> <a href="./src/onebusaway/types/stops_for_location_list_response.py">StopsForLocationListResponse</a></code> | ||
|
||
# ArrivalAndDepartureForStop | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import ArrivalAndDepartureForStopRetrieveResponse | ||
from onebusaway.types import ArrivalAndDepartureForStopRetrieveResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrival_and_departure_for_stop.<a href="./src/open_transit/resources/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/open_transit/types/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/open_transit/types/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code> | ||
- <code title="get /api/where/arrival-and-departure-for-stop/{stopID}.json">client.arrival_and_departure_for_stop.<a href="./src/onebusaway/resources/arrival_and_departure_for_stop.py">retrieve</a>(stop_id, \*\*<a href="src/onebusaway/types/arrival_and_departure_for_stop_retrieve_params.py">params</a>) -> <a href="./src/onebusaway/types/arrival_and_departure_for_stop_retrieve_response.py">ArrivalAndDepartureForStopRetrieveResponse</a></code> | ||
|
||
# ArrivalsAndDeparturesForStop | ||
|
||
Types: | ||
|
||
```python | ||
from open_transit.types import ArrivalsAndDeparturesForStopListResponse | ||
from onebusaway.types import ArrivalsAndDeparturesForStopListResponse | ||
``` | ||
|
||
Methods: | ||
|
||
- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivals_and_departures_for_stop.<a href="./src/open_transit/resources/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/open_transit/types/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code> | ||
- <code title="get /api/where/arrivals-and-departures-for-stop/{stopID}.json">client.arrivals_and_departures_for_stop.<a href="./src/onebusaway/resources/arrivals_and_departures_for_stop.py">list</a>(stop_id) -> <a href="./src/onebusaway/types/arrivals_and_departures_for_stop_list_response.py">ArrivalsAndDeparturesForStopListResponse</a></code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.