我想在项目中使用OLA API。所以我跟着OLA的official docs并使用python请求尝试了以下内容。该请求期望从源到目的地的乘车估计响应。
import requests
headers = {'X-APP-TOKEN' : "your_api_token"}
payload= {'pickup_lat': 12.9490936, 'pickup_lng': 77.67773056, 'drop_lat': 12.9190934, 'drop_lng': 77.1777356, 'category': 'micro'}
response = requests.get('https://devapi.olacabs.com/v1/products', params=payload, headers=headers)
print(response.json())
正如文档中所提到的,我在请求标头中也包含了 X-APP-TOKEN 。但我收到了以下问题。
{'code': 'invalid_partner_key', 'message': 'Partner key is not authorized'}
任何帮助都将受到高度赞赏。
答案 0 :(得分:5)
测试时需要使用以下网址(沙盒):
答案 1 :(得分:0)
使用
https://sandbox-t1.olacabs.com//v1/products
而不是
https://devapi.olacabs.com//v1/products
在制定乘车可用性api请求时。
例如。 得到 https://sandbox-t1.olacabs.com//v1/products?pickup_lat=12.9491416&pickup_lng=77.64298&category=mini
接头: [{ “键”: “X-APP-TOKEN”, “值”: “2e987510441744ceabbbe8b4f9382e93”, “描述”: “”}]
响应:
{
"categories": [
{
"id": "mini",
"display_name": "Mini",
"currency": "INR",
"distance_unit": "kilometre",
"time_unit": "minute",
"eta": -1,
"distance": -1,
"ride_later_enabled": "true",
"image": "http://d1foexe15giopy.cloudfront.net/mini.png",
"all_cabs": [],
"cancellation_policy": {
"cancellation_charge": 50,
"currency": "INR",
"cancellation_charge_applies_after_time": 10,
"time_unit": "minute"
},
"fare_breakup": [
{
"type": "flat_rate",
"minimum_distance": 5,
"minimum_time": 1,
"base_fare": "150.0",
"minimum_fare": "180.0",
"cost_per_distance": "37.5",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "9.0",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "flat_rate",
"minimum_distance": 5,
"minimum_time": 1,
"base_fare": "135.0",
"minimum_fare": "166.5",
"cost_per_distance": "33.0",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "9.0",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "flat_rate",
"minimum_distance": 5,
"minimum_time": 1,
"base_fare": "150.0",
"minimum_fare": "180.0",
"cost_per_distance": "45.0",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "9.0",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "flat_rate",
"minimum_distance": 5,
"minimum_time": 6,
"base_fare": "150.0",
"minimum_fare": "180.0",
"cost_per_distance": "30.0",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "1.5",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "flat_rate",
"minimum_distance": 5,
"minimum_time": 6,
"base_fare": "150.0",
"minimum_fare": "180.0",
"cost_per_distance": "22.5",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "1.5",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "airport drop",
"minimum_distance": 0,
"minimum_time": 0,
"base_fare": "75.0",
"minimum_fare": "90.0",
"cost_per_distance": "16.5",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "1.5",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "airport pickup",
"minimum_distance": 0,
"minimum_time": 0,
"base_fare": "75.0",
"minimum_fare": "90.0",
"cost_per_distance": "12.0",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "1.5",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
},
{
"type": "flat_rate",
"minimum_distance": 0,
"minimum_time": 0,
"base_fare": "75.0",
"minimum_fare": "90.0",
"cost_per_distance": "12.0",
"waiting_cost_per_minute": 0,
"ride_cost_per_minute": "1.5",
"surcharge": [],
"rates_lower_than_usual": false,
"rates_higher_than_usual": true
}
]
}
],
"ride_estimate": {}
}