Appearance
定位 API
定位API提供了多种方式来获取设备或IP的地理位置信息,包括基站/WiFi定位和IP定位。
智能硬件定位 API
接口描述
通过基站或WiFi信息获取当前位置的地理信息。
请求方式
| URL | 请求方式 |
|---|---|
| https://lbs.xiaojukeji.com/api/v2/locrgeo | POST、GET |
请求
查询参数(GET)
| 参数名 | 必选 | 类型 | 描述 | 示例值 |
|---|---|---|---|---|
| key | 是 | string | API Key | YOUR_API_KEY |
| accesstype | 是 | string | 接入网络方式,1-移动网络 2-wifi 3-融合定位 | 1 |
| diu | 否 | string | 设备唯一编号 | 123456 |
| type | 否 | string | 基站类型,0-未知,1-GTW,2-CDMA,3-LTE,默认为2 | 1 |
| bts | 否 | string | 接入基站信息 | 460,11,5766,17005108,85,1 |
| nearbts | 否 | string | 周边基站信息,多个用 | 分隔 | 460,11,5766,17005108,85,1|460,11,5767,17005109,86,1 |
| historybts | 否 | string | 历史基站信息,多个用 | 分隔 | 460,11,5766,17005108,85,1|460,11,5767,17005109,86,1 |
| mmac | 否 | string | 已连接WiFi信息 | c0:b8:e6:e2:e3:34,-41,TPLink,0 |
| macs | 否 | string | WiFi列表中的WiFi信息,多个用 | 分隔 | c0:b8:e6:e2:e3:34,-41,TPLink,0|c0:b8:e6:e2:e3:35,-45,OfficeWiFi,0 |
BTS 字段说明
基站信息格式为逗号分隔的 6 个字段:mcc,mnc_sid,lac_nid,cellid_bsid,rssi,cage
| 字段 | 类型 | 说明 | 示例值 |
|---|---|---|---|
| mcc | int | 基站 MCC(移动国家码) | 460 |
| mnc_sid | int | GTW 基站 MNC / CDMA 基站 SID | 11 |
| lac_nid | int | GTW 基站 LAC / CDMA 基站 NID | 5766 |
| cellid_bsid | int | GTW 基站 CID / CDMA 基站 BSID | 17005108 |
| rssi | int | 基站信号强度(dBm) | 85 |
| cage | int | 基站新鲜度 | 1 |
示例: 460,11,5766,17005108,85,1
MMAC 字段说明
WiFi 信息格式为逗号分隔的 4 个字段:mac,signal,ssid,fresh
| 字段 | 类型 | 说明 | 示例值 |
|---|---|---|---|
| mac | string | WiFi MAC 地址 | c0:b8:e6:e2:e3:34 |
| signal | int | WiFi 信号强度(dBm) | -41 |
| ssid | string | WiFi 名称 | TPLink |
| fresh | int | WiFi 新鲜度(秒),表示信号不变持续的时间。新鲜度值越大(数据越陈旧),偏离实际位置可能越大,默认为 0 | 0 |
示例: c0:b8:e6:e2:e3:34,-41,TPLink,0
请求体参数(POST)
当使用POST方法时,请求体应为 LocRgeoRequest 模型的JSON格式。
json
{
"accesstype": "接入网络方式",
"bts": "接入基站信息",
"diu": "设备唯一编号",
"historybts": "历史基站信息",
"macs": "WiFi 列表信息",
"mmac": "已连接 WiFi 信息",
"nearbts": "周边基站信息",
"type": "基站类型"
}请求示例
GET
shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/locrgeo?key=YOUR_API_KEY&bts=460%2C14183%2C2%2C31322%2C-55%2C0&nearbts=&accesstype=1&type=2"POST
shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/locrgeo?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"accesstype": "1",
"bts": "460,14183,2,31322,-55,0",
"nearbts": "",
"type": "2"
}'响应
成功响应为 LocRgeoResponse 模型的JSON格式。
json
{
"status": "状态码,整数",
"msg": "返回消息",
"trace_id": "请求追踪 ID",
"results": [
{
"city": "城市",
"province": "省份",
"poi": "POI 名称",
"radius": "定位半径,单位米",
"location": {
"lat": "纬度,浮点数",
"lng": "经度,浮点数"
}
}
]
}响应示例
json
{
"status": 10000,
"msg": "success",
"trace_id": "0ac5186e67e50a9c190b048d5ef3dab0",
"results": [
{
"city": "石家庄市",
"location": {"lat": 39.868578, "lng": 116.437006},
"poi": "体坛中医医院-南3门",
"province": "河北省",
"radius": 1000
}
]
}IP定位 API
接口描述
通过IP地址,获取其IP所在的大致位置。
请求方式
| URL | 请求方式 |
|---|---|
| https://lbs.xiaojukeji.com/api/v2/iplocation | POST、GET |
请求
查询参数(GET)
| 参数名 | 必选 | 类型 | 描述 | 示例值 |
|---|---|---|---|---|
| key | 是 | string | API Key | YOUR_API_KEY |
| ip | 是 | string | IP地址 | 1.2.3.4 |
请求体参数(POST)
当使用POST方法时,请求体应为JSON对象,包含ip字段。
请求示例
GET
shell
curl -X GET "https://lbs.xiaojukeji.com/api/v2/iplocation?key=YOUR_API_KEY&ip=1.2.3.4"POST
shell
curl -X POST "https://lbs.xiaojukeji.com/api/v2/iplocation?key=YOUR_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"ip": "1.2.3.4"
}'响应
成功响应为 IPLocationRPCResponse 模型的JSON格式。
json
{
"status": "状态码,整数",
"msg": "返回消息",
"trace_id": "请求追踪 ID",
"results": {
"city": "城市",
"country": "国家",
"district": "区县",
"location": {
"lat": "纬度,浮点数",
"lng": "经度,浮点数"
},
"province": "省份"
}
}响应示例
json
{
"status": 10000,
"msg": "success",
"trace_id": "0ac5186e67e50a9c190b048d5ef3dab0",
"results": {
"city": "北京市",
"country": "中国",
"district": "海淀区",
"location": {"lat": 39.986989, "lng": 116.29522},
"province": "北京市"
}
}