blablacar客户端api
BlaBlaCar-A的Python项目详细描述
blablacar api客户端python库
轻松搜索旅行!
安装
适用于2.7.x和3.x python。
pip install blablacar-api
使用量
fromblablacarapiimportBlaBlaCarApi# initialize APIapi=BlaBlaCarApi(api_key="__your_api_key_here__")# fetch trips from London to Paristrips=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 tripsfortripintrips.trips:print("%s: %s -> %s"%(trip.departure_date,trip.departure_place['address'],trip.arrival_place['address']))# fetch data for one trip using trip idsingle_trip=api.trip(trip.permanent_id)# pagingtrips.pager.has_next()# True or Falsetrips.pager.next()# returns 2 if the current page is 1trips.pager.has_previous()# True or Falsetrips.pager.previous()# returns False if the current page is 1, and it returns 1 if current page is 2
地区
api=BlaBlaCarApi(api_key="__your_blablacar_api_key_here__",locale="en_GB",currency="en_GB")
调试
如果要使用有关api调用的数据调试代码。
# initialize with debug=Trueapi=BlaBlaCarApi(api_key="...",debug=True)# after every API call the client library will automatically print all the data to standard outputapi.trips(...)# and you can always have all debug data in your codedebug_data=api.request.debug.show()
官方文件
有关详细信息,请访问官方文档:https://dev.blablacar.com/docs/versions/1.0