https://api.map.baidu.com/locapi/v2 // POST请求| 参数名称 | 参数含义 | 类型 | 备注 |
|---|---|---|---|
| key | 用户唯一标识,用户可在API控制台申请,应用类型建议选择服务端 | string | 必选 |
| src | 定位请求来源,厂商标 识,比如(baidu),开发者可自定义 | string | 必选 |
| prod | 产品线名称,比如(baiduwatch),开发者可自定义 | string | 必选 |
| ver | 申请服务版本号,目前只提供1.0服务 | string | 必选 |
| trace | 是否开启trace,若为true,则将定位记录 到鹰眼(暂不开通) | bool | 必选 |
| 参数名称 | 参数含义 | 类型 | 备注 |
|---|---|---|---|
| accesstype | 移动端接入网络方式 可选值:移动接入网络:0wifi接入网络:1仅gps坐标转换:2默认值:无 | int | 必选 |
| smac | 手机mac码 默认值:无此参数能够提高定位精度和准确度,且定位不到时可依据此参数进行跟踪排查,如没有则无法排查和跟踪问题。 | string | 非必选,但建议填写 |
| clientip | 移动网关IP 默认值:无此参数能够提高定位精度和准确度,且定位不到时可依据此参数进行跟踪排查,如没有则无法排查和跟踪问题。 | string | 非必选,但建议填写 |
| cdma | 是否为cdma。非cdma:0; cdma:1 默认值为:0 | int | accesstype=0时,必选 |
| imsi | 移动用户识别码 默认值:无此参数能够提高定位精度和准确度,且定位不到时可依据此参数进行跟踪排查,如没有则无法排查和跟踪问题。 | string | 非必选,但建 议填写 |
| gps | 手机GPS数据取值规则: 经度|纬度|半径 | string | accesstype=2时,必选 |
| network | 无线网络类型 GSM/GPRS/EDGE/HSUPA/HSDPA/WCDMA (注意大写) | string | accesstype=0时,必选 |
| tel | 手机号码 | string | 非必选 |
| bts | 基站信息,非CDMA格式为:mcc, mnc,lac,cellid,signal;其中lac,cellid必须填写,signal如无法获取请填写50,前两位mcc, mnc 如无法获取,请填写-1 CDMA格式为:sid,nid,bid,lon,lat,signal 其中lon,lat可为空,格式为:sid,nid,bid,,,signal 为保证定位效果,请尽量全部填写 | string | accesstype=0时,必选 |
| nearbts | 周边基站信息 基站信息1|基站信息2|基站信息3…. | string | 非必选 |
| mmac | 已连热点mac信息 mac,signal,ssid。 如:f0:7d:68:9e:7d:18,-41,TPLink 非必选,但强烈建议填写 | string | 非必选 |
| macs | WI-FI列表中mac信息 单mac信息同mmac,mac之间使用“|”分隔。 必须填写 2 个及 2 个以上,30 个 以内的方可正常定位。请不要包含移动WI-FI信息 | string | accesstype=1时,必选 |
| coor | 可指定坐标系(GCJ02|BD09LL),注意大写。 国内(包含港澳台)默认返回BD09LL坐标系。 国外不论填写任何坐标系类型,均返回WGS84坐标系。 | string | 非必选 |
| output | 返回数据格式类型(注意大写) 可选值:JSON, XML 默认值:JSON 一期只支持JSON | string | 非必选 |
| ctime | 客户端时间戳 | string | 必选 |
| need_rgc | 返回地址信息,默认不返回Y : 返回rgc结果 N : 不返回rgc结果 | string | 非必选 |
| 结果字段 | 字段含义 | 类型 |
|---|---|---|
| type | 定位类型,0:没有得到定位结果;1:gps 定位结果;2:wifi定位结果;3:混合定位 结果;4:基站定位结果;5:其他-- | int |
| location | 定位经纬度(经度,纬度) | string |
| radius | 定位精度半径,单位:米 | int |
| desc | 位置描述 | string |
| country | 国家 | string |
| province | 省 | string |
| city | 市 | string |
| citycode | 城市编码 | string |
| district | 县区 | string |
| road | 道路名 | string |
| ctime | 客户端请求时间戳,批量请求时用于匹配 服务端响应和客户端请求 | string |
| bldg | 建筑物简称 | string |
| bldgid | 建筑物ID | string |
| bldgname | 建筑物 | string |
| floor | 楼层 | string |
| indoor | 是否室内:0:室外 1:室内 | string |
| error | 定位是否成功 0: 成功 -1:失败 | int |
{
"ver": "1.0",
"trace": false,
"prod": "test_loc_api",
"src": "baidu_loc_api",
"key": "XXXXXXXXXXXXXXXXXXXXXXXXXXX",
"body": [{
"bts": "460,0,4189,8869,-63",
"output": "JSON",
"accesstype": 0,
"macs":"70:ba:ef:d0:87:91,-42,|70:ba:ef:d1:0e:01,-45,|70:ba:ef:cc:98:11,-56,|dc:fe:18:c9:94:ce,-87,|58:60:5f:68:d8:30,-89,|94:d9:b3:cf:a2:db,-91,|30:fc:68:ac:c6:ae,-91,|c8:3a:35:32:48:c8,-94,",
"imei": "xxxxxxxxxxxxxxx",
"ctime": "1551178833",
"nearbts":"460,0,4189,33989,-81|460,0,4189,8868,-83|460,0,4189,33988,-84|460,0,4189,239,-86|460,0,4189,32659,-98|460,0,4189,8867,-99",
"cdma": 0,
"need_rgc": "Y",
"network": "GPRS"
},
{
"accesstype": 0,
"imei": "xxxxxxxxxxxxxxx",
"clientip": "232.111.11.240",
"cdma": 0,
"imsi": "xxxxxxxxxxxxxxx",
"network": "GPRS",
"bts": "510,11,25182,40081,-83",
"macs": "e0:36:76:e8:11:78,-18,1",
"coor": "bd09ll",
"output": "JSON",
"ctime": "1551178833",
"need_rgc": "Y"
},
{
"accesstype": 0,
"imei": "xxxxxxxxxxxxxxx",
"cdma": 0,
"imsi": "xxxxxxxxxxxxxxx",
"network": "GSM",
"bts": "460,0,4163,21297934,-124",
"nearbts": "460,0,-1,-1,13|460,0,-1,-1,29",
"macs":"C8:E7:D8:33:B4:7C,-52,73cun|8C:A6:DF:DF:4B:14,-54,nolimit|E4:6F:13:CC:15:41,-57,weizhiweikeyong|E4:6F:13:CC:15:40,-64,WZWIT|66:14:4B:55:C8:48,-69,CMCC|54:B1:21:A6:81:D5,-73,HUAWEI-E5573-81D5|02:6B:E7:92:B1:73,-76,VANS|20:F4:1B:B6:9F:46,-78,ydnc",
"coor": "GCJ02",
"output": "JSON",
"ctime": "1551178833",
"need_rgc": "Y"
}
]
}
{
"errcode": 0,
"msg": "Query success.",
"body": [
{
"type": 2,
"location": "116.298457,39.848625",
"radius": 41,
"country": "中国",
"province": "北京市",
"city": "北京市",
"citycode": "131",
"district": "丰台区",
"road": "丰台南路44号",
"ctime": "1551178833",
"indoor": "1",
"error": 0
},
{
"type": 4,
"location": "107.614218,-6.941022",
"radius": 111,
"country": "Indonesia",
"province": "Jawa Barat",
"city": "Bandung City",
"citycode": "34544",
"district": "",
"road": "Jalan Sriwijaya",
"ctime": "1551178833",
"indoor": "0",
"error": 0
},
{
"type": 2,
"location": "116.352743,39.941695",
"radius": 15,
"country": "中国",
"province": "北京市",
"city": "北京市",
"citycode": "131",
"district": "西城区",
"road": "西直门外大街1号院-3号",
"ctime": "1551178833",
"bldg": "bjxcqkdmall",
"bldgid": "1266783613064577023",
"bldgname": "凯德MALL(西直门嘉茂店)",
"floor": "f4",
"indoor": "1",
"error": 0
}
]
}
| 状态码 | 错误描述 |
|---|---|
| 0 | 正常 |
| 101 | Missing field : body (size should > 0 && < 3) |
| 102 | Request is empty |
| 103 | 参数错误,错误详情请见“msg”字段 |
| 104 | Unexpected err, please contact with us |
| 601 | Failed to authenticate for lack of AK |
| 700 | Failed to authenticate for invaid AK : ${key}(key校验失败) |
| 710 | Failed to authenticate for invaid IP : ${ip} (服务端IP校验失败) |
| 711 | APP SN校验失败。当用户请求的SN和服务端计算出来的SN不相等的时候提示SN校验失败。可考虑在控制台-我的应用中将AK的请求校验方式改为IP白名单 |
| 740 | Failed to authenticate for api loc is forbidden.(服务被禁用,一般不会出现) |
| 752 | Failed to authenticate for bad user.(非法用户) |
| 760 | Failed to authenticate for servive is not exist(服务不存在,一般不会出现) |
| 761 | Failed to authenticate for servive is off the assembly line(服务已下线,一般不会出现) |
| 801 | Failed to authenticate for exceeding total quota(总用量超限,一般不会出现) |
| 802 | Failed to authenticate for exceeding daily quota(${quota_num}) (日用量超限) |
| 901 | Failed to authenticate for exceeding concurrency(${min_quota}) (分钟并发超限) |
| 902 | Failed to authenticate for exceeding concurrency(${min_quota}) (日用 量与分钟并发均超限) |
| 其他500+错误 | Failed to authenticate for unexpected error, please contact with us |
| 750 | Failed to authenticate for user is not exist |
| 751 | Failed to authenticate for user is deleted by yourself |
