"Python Interface to Travel Time."
Project description
Travel Time Python SDK
Travel Time Python SDK helps users find locations by journey time rather than using ‘as the crow flies’ distance.
Time-based searching gives users more opportunities for personalisation and delivers a more relevant search.
Usage
Authentication
In order to authenticate with Travel Time API, you will have to supply the Application Id and Api Key.
from traveltimepy.sdk import TravelTimeSdk
sdk = TravelTimeSdk('YOUR_API_ID', 'YOUR_API_KEY')
Isochrones (Time Map)
Given origin coordinates, find shapes of zones reachable within corresponding travel time.
departure_search1 = DepartureSearch(
id='search_1',
coords=Coordinates(lat=51.507609, lng=-0.128315),
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=900,
transportation=PublicTransport()
)
departure_search2 = DepartureSearch(
id='search_2',
coords=Coordinates(lat=51.507609, lng=-0.128315),
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=900,
transportation=Driving()
)
arrival_search = ArrivalSearch(
id='search_3',
coords=Coordinates(lat=51.507609, lng=-0.128315),
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=900,
transportation=PublicTransport(),
range=Range(enabled=True, width=3600)
)
union = Union(
id='search_4',
search_ids=['search_2', 'search_3']
)
intersection = Intersection(
id='search_5',
search_ids=['search_2', 'search_3']
)
response = sdk.time_map(
[arrival_search],
[departure_search1, departure_search2],
[union],
[intersection]
)
Distance Matrix (Time Filter)
Given origin and destination points filter out points that cannot be reached within specified time limit.
locations = [
Location(id='London center', coords=Coordinates(lat=51.508930, lng=-0.131387)),
Location(id='Hyde Park', coords=Coordinates(lat=51.508824, lng=-0.167093)),
Location(id='ZSL London Zoo', coords=Coordinates(lat=51.536067, lng=-0.153596))
]
departure_search = DepartureSearch(
id='forward search example',
arrival_location_ids=['Hyde Park', 'ZSL London Zoo'],
departure_location_id='London center',
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=3600,
transportation=PublicTransport(type='bus'),
properties=[Property.TRAVEL_TIME],
full_range=FullRange(enabled=True, max_results=3, width=600)
)
arrival_search = ArrivalSearch(
id='backward search example',
departure_location_ids=['Hyde Park', 'ZSL London Zoo'],
arrival_location_id='London center',
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=3800,
transportation=PublicTransport(type='bus'),
properties=[Property.TRAVEL_TIME, Property.FARES, Property.ROUTE],
)
response = sdk.time_filter(locations, [departure_search], [arrival_search])
Time Filter (Fast)
A very fast version of time_filter()
locations = [
Location(id='London center', coords=Coordinates(lat=51.508930, lng=-0.131387)),
Location(id='Hyde Park', coords=Coordinates(lat=51.508824, lng=-0.167093)),
Location(id='ZSL London Zoo', coords=Coordinates(lat=51.536067, lng=-0.153596))
]
many_to_one = ManyToOne(
id='many-to-one search example',
departure_location_ids=['Hyde Park', 'ZSL London Zoo'],
arrival_location_id='London center',
transportation=Transportation(type='public_transport'),
arrival_time_period='weekday_morning',
travel_time=1900,
properties=[Property.TRAVEL_TIME, Property.FARES]
)
one_to_many = OneToMany(
id='one-to-many search example',
arrival_location_ids=['Hyde Park', 'ZSL London Zoo'],
departure_location_id='London center',
transportation=Transportation(type='public_transport'),
arrival_time_period='weekday_morning',
travel_time=1900,
properties=[Property.TRAVEL_TIME, Property.FARES]
)
response = sdk.time_filter_fast(locations, [many_to_one], [one_to_many])
Routes
Returns routing information between source and destinations.
locations = [
Location(id='London center', coords=Coordinates(lat=51.508930, lng=-0.131387)),
Location(id='Hyde Park', coords=Coordinates(lat=51.508824, lng=-0.167093)),
Location(id='ZSL London Zoo', coords=Coordinates(lat=51.536067, lng=-0.153596))
]
departure_search = DepartureSearch(
id='departure search example',
arrival_location_ids=['Hyde Park', 'ZSL London Zoo'],
departure_location_id='London center',
departure_time=datetime(2022, 11, 24, 12, 0, 0),
transportation=PublicTransport(type='bus'),
properties=[Property.TRAVEL_TIME],
full_range=FullRange(enabled=True, max_results=3, width=600)
)
arrival_search = ArrivalSearch(
id='arrival search example',
departure_location_ids=['Hyde Park', 'ZSL London Zoo'],
arrival_location_id='London center',
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
transportation=PublicTransport(type='bus'),
properties=[Property.TRAVEL_TIME, Property.FARES, Property.ROUTE],
)
response = sdk.routes(locations, [departure_search], [arrival_search])
Time Filter (Postcodes)
Find reachable postcodes from origin (or to destination) and get statistics about such postcodes.
departure_search = DepartureSearch(
id='public transport from Trafalgar Square',
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=1800,
coords=Coordinates(lat=51.507609, lng=-0.128315),
transportation=PublicTransport(),
properties=[Property.TRAVEL_TIME, Property.DISTANCE]
)
arrival_search = ArrivalSearch(
id='public transport to Trafalgar Square',
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=1800,
coords=Coordinates(lat=51.507609, lng=-0.128315),
transportation=PublicTransport(),
properties=[Property.TRAVEL_TIME, Property.DISTANCE]
)
response = sdk.postcodes([departure_search], [arrival_search])
Time Filter (Postcode Sectors)
Find sectors that have a certain coverage from origin (or to destination) and get statistics about postcodes within such sectors.
departure_search = DepartureSearch(
id='public transport from Trafalgar Square',
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=200,
coords=Coordinates(lat=51.507609, lng=-0.128315),
reachable_postcodes_threshold=0.1,
transportation=PublicTransport(),
properties=[Property.TRAVEL_TIME_ALL, Property.TRAVEL_TIME_REACHABLE]
)
arrival_search = ArrivalSearch(
id='public transport to Trafalgar Square',
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=200,
coords=Coordinates(lat=51.507609, lng=-0.128315),
reachable_postcodes_threshold=0.1,
transportation=PublicTransport(),
properties=[Property.COVERAGE]
)
response = sdk.sectors([departure_search], [arrival_search])
Time Filter (Postcode Districts)
Find reachable postcodes from origin (or to destination) and get statistics about such postcodes.
departure_search = DepartureSearch(
id='public transport from Trafalgar Square',
departure_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=200,
coords=Coordinates(lat=51.507609, lng=-0.128315),
reachable_postcodes_threshold=0.1,
transportation=PublicTransport(),
properties=[Property.TRAVEL_TIME_ALL, Property.TRAVEL_TIME_REACHABLE]
)
arrival_search = ArrivalSearch(
id='public transport to Trafalgar Square',
arrival_time=datetime(2022, 11, 24, 12, 0, 0),
travel_time=200,
coords=Coordinates(lat=51.507609, lng=-0.128315),
reachable_postcodes_threshold=0.1,
transportation=PublicTransport(),
properties=[Property.COVERAGE]
)
response = sdk.districts([departure_search], [arrival_search])
Geocoding (Search)
Match a query string to geographic coordinates.
response = sdk.geocoding(query='Parliament square', limit=30)
Reverse Geocoding
Match a latitude, longitude pair to an address.
response = sdk.geocoding_reverse(lat=51.507281, lng=-0.132120)
Map Info
Get information about currently supported countries.
response = sdk.map_info()
Supported Locations
Find out what points are supported by the api.
locations = [
Location(id='Kaunas', coords=Coordinates(lat=54.900008, lng=23.957734)),
Location(id='London', coords=Coordinates(lat=51.506756, lng=-0.12805)),
Location(id='Bangkok', coords=Coordinates(lat=13.761866, lng=100.544818)),
Location(id='Lisbon', coords=Coordinates(lat=38.721869, lng=-9.138549)),
]
response = sdk.supported_locations(locations)
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
Built Distribution
Hashes for traveltimepy-2.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa2d75f58f0c7bdfd3ec56d02d46a8f2826d3414fc9993cb3a7e01c5240a0d2d |
|
MD5 | 13ee79728284058887e093b77313a3ad |
|
BLAKE2b-256 | 52cb6e6fce9038d6a22e8b172a86e5b3df509d87778d31612651369231596066 |