UberX 没有确切的预估价格

No exact amount estimate price for UberX

目前在应用程序中,请求 UberX 立即为您提供准确的报价,但在 Python API 中,我找不到它。我只能找到成本的范围。具体报价在哪里?

尝试使用“POST /v1.2/requests/estimate

示例请求

curl -X POST \
 -H 'Authorization: Bearer <TOKEN>' \
 -H 'Accept-Language: en_US' \
 -H 'Content-Type: application/json' \
 -d '{
   "start_latitude": 37.7752278,
   "start_longitude": -122.4197513,
   "end_latitude": 37.7773228,
   "end_longitude": -122.4272052
 }' "https://api.uber.com/v1.2/requests/estimate"

我建议您也使用 "product_id" - 以获得您需要的产品的价格。否则,如果提供 none,它将默认为给定位置的最便宜产品。

您将收到如下回复:

{
"fare": {
"value": 5.73,
"fare_id": "d30e732b8bba22c9cdc10513ee86380087cb4a6f89e37ad21ba2a39f3a1ba960",
"expires_at": 1476953293,
"display": ".73",
"currency_code": "USD",
"breakdown": [
 {
   "type": "promotion",
   "value": -2.00,
   "name": "Promotion"
 },
 {
   "type": "base_fare",
   "notice": "Fares are slightly higher due to increased demand",
   "value": 7.73,
   "name": "Base Fare"
 }
 ]
},
"trip": {
"distance_unit": "mile",
"duration_estimate": 540,
"distance_estimate": 2.39
},
"pickup_estimate": 2
}

与 Pyton SDK 相关 - 请检查:https://developer.uber.com/docs/riders/ride-requests/tutorials/api/python。您需要验证您的用户,然后获得您想要使用的产品,然后获得预付费用(如果产品支持此:upfront_fare_enabled 字段设置为 true)。之后你可以预订一程。如何做到这一点的代码在文档 link 中,我也已发送:

# Get products for a location
response = client.get_products(37.77, -122.41)
products = response.json.get('products')

product_id = products[0].get('product_id')

# Get upfront fare and start/end locations
estimate = client.estimate_ride(
product_id=product_id,
start_latitude=37.77,
start_longitude=-122.41,
end_latitude=37.79,
end_longitude=-122.41,
seat_count=2
)
fare = estimate.json.get('fare')

# Request a ride with upfront fare and start/end locations
response = client.request_ride(
product_id=product_id,
start_latitude=37.77,
start_longitude=-122.41,
end_latitude=37.79,
end_longitude=-122.41,
seat_count=2,
fare_id=fare['fare_id']
)

request = response.json
request_id = request.get('request_id')

# Request ride details using `request_id`
response = client.get_ride_details(request_id)
ride = response.json

# Cancel a ride
response = client.cancel_ride(request_id)
ride = response.json