Skip to main content

BlaBlaCar Client Api

Project description

BlaBlaCar API Client Python Library

PyPI version

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
BlaBlaCar_API-0.2.2-py2.py3-none-any.whl (8.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Apr 24, 2018
BlaBlaCar API-0.2.2.tar.gz (6.4 kB) Copy SHA256 hash SHA256 Source None Apr 24, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page