A Python client for the Department for Transport Bus Open Data Service API
Project description
bods-client
A Python client for the Department for Transport Bus Open Data Service API
Installation
pip install bods-client
Example
GTFS RT
All the vehicle locations for vehicles in a geographical location can be obtained
using the get_gtfs_rt_data_feed
method with a boundng box.
from bods_client.client import BODSClient
from bods_client.models import BoundingBox
# An API key can be obtained by registering with the Bus Open Data Service
# https://data.bus-data.dft.gov.uk/account/signup/
>> API_KEY = "api-key"
>> bods = BODSClient(api_key=API_KEY)
>> box = BoundingBox(min_longitude=-0.54, min_latitude=51.26, max_longitude=0.27, max_latitide=51.75)
>> message = bods.get_gtfs_rt_data_feed(bounding_box=box)
>> message.entity[0]
id: "421354378097713049"
vehicle {
trip {
trip_id: ""
route_id: ""
}
position {
latitude: 51.712860107421875
longitude: -0.38401100039482117
bearing: 170.0
}
timestamp: 1614396229
vehicle {
id: "7214"
}
}
This returns a google.transit.gtfs_realtime_pb2.FeedMessage
object. More details about
General Transit Feed Specification Realtime Transit (GTFS-RT) can be found
here.
License
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
bods-client-0.3.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for bods_client-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2faba370c3ff17b011ffba189130f05a01facebb20052a01292e1313e6153d76 |
|
MD5 | f984ddb5f7a796e6c2c7f06aba1ce509 |
|
BLAKE2b-256 | 3ee2403fa3551e0f6983684807c815cb6093739e2622143486badd99b3225d6c |