批量请求接口 最后更新时间: 2021年01月22日
产品介绍
特别说明:受产品策略调整影响,自2020年11月起,建议您不再使用此批量接口。后续平台会逐步废弃并下线此服务。
批量接口通过用户传入合并后的请求,同时返回多个请求的顺序集合,目前最多支持20个子请求。 返回的顺序与子请求的顺序一致。
使用API前您需先申请Key,若无高德地图API账号需要先申请账号。
适用场景
希望批量得到接口返回数据的用户。
使用说明
在此必须特别说明,使用批量接口时,key的配额和QPS会根据子请求来进行控制。
例如:一次批量请求里面有20个驾车路径规划请求,且在同一秒发来请求,则此key的QPS消耗为20
一、申请”web服务 API”密钥(Key);
二、拼接请求,第一步申请的Key需作为必填参数一同发送,父请求的Key和子请求的Key请务必保持一致;
三、batch接口本身为post请求接口,子请求只支持get方式请求,以json形式返回数据结构;子请求参数请参考各接口文档进行拼接,如无特殊声明,接口的输入参数和输出数据编码全部统一为UTF-8;
四、默认所有的子请求都会继承当前请求的header头;
五、为了保证以后升级兼容,建议header里指明Content-Type:application/json;
六、batch接口当前支持所有v3(请求中带v3字样)接口。
批量请求接口
- 批量请求API父请求服务地址
https://restapi.amap.com/v3/batch?key=<用户的key>
- POST的body体之中内容示例
{ "ops": [ { "url": "/v3/place/around?offset=10&page=1&key=<您的key>&location=116.50394379585519,39.278209477408794&output=json&radius=100000&types=080000" }, { "url": "/v3/place/around?offset=10&page=1&key=<您的key>&location=118.50394379585519,39.278209477408794&output=json&radius=100000&types=080000" } ] }
需要在content-type之中指定“application/json”
- 返回结果
名称 | 含义 | 规则说明 | |
---|---|---|---|
status | HTTP状态码 | 返回内容为HTTP状态码,200表示成功,其他错误请查阅HTTP状态码文档。 与高德API的接口错误码以及状态码无对应关系。 | |
body | 返回结果的列表 | ||
接口返回结果 | 接口的返回结果 | 具体规则和内容请参照每个接口的文档 |
- 响应示例
[
{
"status": 200,
"body": {
"suggestion": {
"keywords": {
},
"cities": {
}
},
"info": "OK",
"status": "1",
"count": "4",
"pois": [
{
"typecode": "080503",
"biz_type": {
},
"id": "B013C16BMA",
"biz_ext": {
},
"address": "武隆南路延伸线交口往北200米路东",
"name": "开心草莓采摘园",
"type": "体育休闲服务;休闲场所;休闲园",
"distance": "2235",
"tel": {
},
"location": "116.483231,39.290303"
},
{
"typecode": "080308",
"biz_type": {
},
"id": "B0FFFZ425C",
"biz_ext": {
},
"address": "宜昌南路185号",
"name": "三星天翔鸟网吧",
"type": "娱乐场所;网吧",
"distance": "2944",
"tel": {
},
"location": "116.496649,39.304055"
},
{
"typecode": "080308",
"biz_type": {
},
"id": "B013C0IMLS",
"biz_ext": {
},
"address": "宜昌南路388号附近",
"name": "梦想网吧",
"type": "娱乐场所;网吧",
"distance": "2975",
"tel": {
},
"location": "116.496564,39.304317"
},
{
"typecode": "080000",
"biz_type": {
},
"id": "B0FFFGQVOF",
"biz_ext": {
},
"address": "宜昌南路173号",
"name": "腾宇网络会所",
"type": "娱乐场所;网吧",
"distance": "2989",
"tel": {
},
"location": "116.496546,39.304447"
}
],
"infocode": "10000"
},
"header": {
"Content-Length": 1145,
"Content-Type": "application/json;charset=UTF-8"
}
},
{
"status": 200,
"body": {
"suggestion": {
"keywords": {
},
"cities": {
}
},
"info": "OK",
"status": "1",
"count": "0",
"pois": {
},
"infocode": "10000"
},
"header": {
"Content-Length": 108,
"Content-Type": "application/json;charset=UTF-8"
}
}