BlaBlaCar Client Api
Project description
BlaBlaCar API Client Python Library
Easily search for trips!
Installation
Works on both 2.7.x and 3.x python.
pip install blablacar
Usage
from blablacarapi import BlaBlaCarApi
# initialize API
api = BlaBlaCarApi(api_key="__your_api_key_here__")
# fetch trips from London to Paris
trips = api.trips(frm="London", to="Paris")
# after fetching you have:
# trips.trips
# trips.top_trips
# trips.pager
# trips.facets
# trips.savings
# trips.distance
# trips.duration
# trips.recommended_price
# iterate over the trips
for trip in trips.trips:
print("%s: %s -> %s" % (trip.departure_date, trip.departure_place['address'], trip.arrival_place['address']))
# fetch data for one trip using trip id
single_trip = api.trip(trip.permanent_id)
# paging
trips.pager.has_next() # True or False
trips.pager.next() # returns 2 if the current page is 1
trips.pager.has_previous() # True or False
trips.pager.previous() # returns False if the current page is 1, and it returns 1 if current page is 2
Locales
api = BlaBlaCarApi(api_key="__your_blablacar_api_key_here__", locale="en_GB", currency="en_GB")
Debugging
If you want to debug your code using the data regarding the API call.
# initialize with debug=True
api = BlaBlaCarApi(api_key="...", debug=True)
# after every API call the client library will automatically print all the data to standard output
api.trips(...)
# and you can always have all debug data in your code
debug_data = api.request.debug.show()
Official documentation
For more information visit official documentation: https://dev.blablacar.com/docs/versions/1.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
BlaBlaCar API-0.2.0.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for BlaBlaCar_API-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b16877dcd29b5abcc95e439a3d256d484b84fccbefe0d4535310bdc5cf3c483 |
|
MD5 | 62f3b2615c23d0e6134f0e54c597d07a |
|
BLAKE2b-256 | 7a8c3d17fa92a351c9f4f96f22f7170b68700df334d7f288050d90a179f0e159 |