POST/v1/transfers/pricing
API 控制台
试一试
向沙箱 API 发送真实请求并查看响应。
凭证
登录后即可从已保存的 API 密钥中选择,无需手动粘贴。
请求体
cURL 请求
bash
curl -X POST 'https://api.sandbox.travelandz.com/v1/transfers/pricing' \
-H 'Authorization: Bearer YOUR_SECRET_KEY' \
-H 'X-Travelandz-Id: YOUR_PUBLIC_KEY:YOUR_PROFILE_CODE' \
-H 'Content-Type: application/json' \
-d '{"gdsprovider":0,"bookingToken":"opaque_offer_token_generated_by_travelandz","searchId":"73a5670b476649a985f0535db1077c05","resultId":"fe94b51ccd0623a9f1adabfbe0614d34","selectedAmenities":["baby_seats","child_booster"],"currency":"USD"}'请填写凭证以发送请求。
此请求需要来自上一次调用的标识符或令牌。请先运行前一个步骤,然后把它的值粘贴到这里。
响应
点击「试一试!」发送请求,响应将显示在此处。
确认所选报价的最终价格,并获取预订所需的令牌。
认证和请求头
| 请求头 | 说明 |
|---|---|
Authorization | Bearer <secret_key>。密钥只能保存在服务器端,不能写入客户端日志。 |
X-Travelandz-Id | <public_key>:<profile_code>,持久化的 profile code 格式为 dp_<12 位字母数字>。 |
LANG | 推荐的语言请求头,也支持 Accept-Language。 |
Content-Type | 带 JSON body 的请求使用 application/json。 |
请求
发送 gdsprovider、所选报价的 bookingToken,以及与之匹配的 searchId 和 resultId。在 selectedAmenities 中加入旅客选择的设施 key。若发送 currency,必须与搜索的货币一致;省略则继承。
请求体结构
gdsproviderTransfer content selector. Currently
0.bookingTokenCopy the
bookingToken of the selected offer.searchIdMust be the
searchId of the selected offer.resultIdMust be the
resultId of the selected offer.selectedAmenitiesselectedAmenities[]When sent, needs at least one unique, non-empty key available in the offer.
currencyLowercase values are accepted and normalized. Defaults to
USD on a new search and is inherited afterwards.languageLegacy field. Prefer the
LANG or Accept-Language header.请求示例
不含设施
json
{
"gdsprovider": 0,
"bookingToken": "opaque_offer_token_generated_by_travelandz",
"searchId": "73a5670b476649a985f0535db1077c05",
"resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
"currency": "USD"
}含设施
json
{
"gdsprovider": 0,
"bookingToken": "opaque_offer_token_generated_by_travelandz",
"searchId": "73a5670b476649a985f0535db1077c05",
"resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
"selectedAmenities": [
"baby_seats",
"child_booster"
],
"currency": "USD"
}成功响应
返回 finalPrice、标准化的设施选择,以及不透明的 pricingToken。
finalPrice.amount 就是应向旅客收取的金额。切勿根据搜索响应或设施数据自行重新计算价格。
响应体结构
finalPricefinalPriceamountAmount to charge, rounded to two decimals.
finalPricecurrencyselectedAmenitiesselectedAmenities[]keyValue to send in
selectedAmenities.selectedAmenities[]nameLocalized name.
selectedAmenities[]descriptionselectedAmenities[]imageUrlselectedAmenities[]pngImageUrlselectedAmenities[]inputTypeselectedAmenities[]includedTrue when the amenity is already part of the offer.
selectedAmenities[]selectableTrue when the amenity can be added to this offer.
selectedAmenities[]selectedTrue when the amenity is part of the priced selection.
pricingTokenOpaque value. Send it to booking or to a reservation change; never decode or modify it.
响应示例
json
{
"finalPrice": {
"amount": 181.97,
"currency": "USD"
},
"selectedAmenities": [
{
"key": "baby_seats",
"name": "Baby seats",
"description": "Your vehicle will have a child safety seat to keep children under age 4 safe.",
"imageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/baby-seats.svg",
"pngImageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/baby-seats.png",
"inputType": "numeric",
"included": false,
"selected": true,
"selectable": true
},
{
"key": "child_booster",
"name": "Child booster",
"description": "Your vehicle will have a child booster seat to keep children from age 4-8 safe.",
"imageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/child-booster.svg",
"pngImageUrl": "https://api.sandbox.travelandz.com/v1/assets/transfers/images/0/amenities/child-booster.png",
"inputType": "numeric",
"included": false,
"selected": true,
"selectable": true
}
],
"pricingToken": "opaque_public_pricing_token_generated_by_travelandz"
}错误
| HTTP | 代码 | 含义 | 建议操作 |
|---|---|---|---|
400 | 请求体、查询参数或路径无效,或包含未知属性。 | 根据 message 数组修正请求。 | |
400 | transfer_invalid_currency | 该货币不在支持列表中。 | 使用受支持的货币。 |
400 | transfer_invalid_language | 请求的语言不受支持。 | 使用文档中列出的语言值之一。 |
429 | transfer_provider_error | 服务暂时被限流。 | 使用指数退避重试。 |
502 | transfer_provider_error | 请求无法完成。 | 不要假定成功。保留标识符,并在该操作可能已创建时查询预订。 |
400 | transfer_invalid_booking_token | booking token 已过期、被修改,或不属于该报价。 | 重新搜索,并使用新选报价的令牌。 |
400 | transfer_invalid_amenities | amenity key 重复、为空,或该报价不提供。 | 发送取自报价或设施目录的唯一 key。 |
400 | transfer_currency_mismatch | 货币与报价、报价单或预订不一致。 | 复用上一步返回的货币,或省略该字段以继承它。 |
503 | 当前无法确认价格。 | 稍后重试。不要预订,也不要向旅客收费。 |
使用说明
每次预订以及确认每次预订变更之前都必须先定价,即使没有选择任何设施。
pricingToken 是不透明的,且仅属于其创建时对应的报价。请原样复制到下一次调用,不要解码或修改;若报价过期,请重新定价。
cURL 示例
bash
curl --request POST \
--url "https://api.sandbox.travelandz.com/v1/transfers/pricing" \
-H "Authorization: Bearer $TRAVELANDZ_SECRET_KEY" \
-H "X-Travelandz-Id: $TRAVELANDZ_PUBLIC_KEY:$TRAVELANDZ_PROFILE_CODE" \
-H "Content-Type: application/json" \
--data '{
"gdsprovider": 0,
"bookingToken": "opaque_offer_token_generated_by_travelandz",
"searchId": "73a5670b476649a985f0535db1077c05",
"resultId": "fe94b51ccd0623a9f1adabfbe0614d34",
"selectedAmenities": [
"baby_seats",
"child_booster"
],
"currency": "USD"
}'