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-api
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.3.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file BlaBlaCar API-0.2.3.tar.gz
.
File metadata
- Download URL: BlaBlaCar API-0.2.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18c19db23cb2b446183b291ab8a9cd57a9caec308397e8512e9a067f662380bb |
|
MD5 | 0a0b6987cb7468d1fd7f7f8df5f240e5 |
|
BLAKE2b-256 | 927a6cfd6cf2a9f4ad8a1771d368631e79aa0392f558d644be46f6d5b9780ef7 |
File details
Details for the file BlaBlaCar_API-0.2.3-py2.py3-none-any.whl
.
File metadata
- Download URL: BlaBlaCar_API-0.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.20.0 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e517fc62018585588d63a27ba52a1b4f2f4d25f939c02a0914f87301883b6d93 |
|
MD5 | 676585b0e2008edbc984880a49a9f983 |
|
BLAKE2b-256 | 4cf796b1ee27b4e80bac648229f255c062040ea91d5f296996d09d440979db80 |