The Geolocation API uses the HTTP protocol to access remote services, supporting the upload of WIFI and base station information through the server to achieve positioning, thereby obtaining latitude and longitude and other location information.
Guidelines
Apply for a
【Web Service API】Key
Enable overseas permissions for the applied Key by submitting a ticket to request overseas permissions
Construct the HTTP request URL, including the Key obtained in Step 1 as a required parameter
Receive and parse the data returned from the HTTP request (in JSON or XML format)
Unless otherwise specified, all input parameters and output data are encoded in
UTF-8。
Geolocation
Geolocation API Service URL
URL | Request Method |
http://sg-apilocate.opnavi.com/position?parameters | GET |
The parameters represent both required and optional parameters. All parameters are separated by the ampersand character (&). The list below enumerates these parameters and their usage rules.
Request Parameters
Parameter Name | Description | Specification | Mandatory | Default |
key | Service Authorization Token | Applying for a Web Service API Key and Submitting a Work Order for Overseas Permissions on Amap Map Official Website | Mandatory | None |
accesstype | Mobile network access method | Optional values: Mobile network: 0 wifi network: 1 Default: None | Required | None |
imei | Phone imei number | This parameter can improve the accuracy and precision of positioning, and can be used for tracking and troubleshooting when positioning fails. Without it, issues cannot be investigated or tracked. | Required | None |
idfa | idfa of iOS phone | This parameter can improve the accuracy and precision of positioning, and can be used for tracking and troubleshooting when positioning fails. Without it, issues cannot be investigated or tracked. | One of them must be filled in with imei | None |
smac | Phone mac address | This parameter can improve the accuracy and precision of positioning, and can be used for tracking and troubleshooting when positioning fails. Without it, issues cannot be investigated or tracked. | Not required, but recommended to fill in | None |
serverip | Gateway IP corresponding to the device accessing the base station | This parameter can improve the accuracy and precision of positioning, and can be used for tracking and troubleshooting when positioning fails. Without it, issues cannot be investigated or tracked. | Not required, but recommended to fill in | None |
cdma | Whether it is cdma | Whether it is cdma or not cdma:0 is cdma:1 | Required when accesstype=0 | 0 |
imsi | Mobile Subscriber Identification Number | This parameter can improve positioning accuracy and precision, and when positioning fails, it can be used for tracking and troubleshooting. Without it, issues cannot be investigated or tracked. | Not required, but recommended to fill in | None |
network | Wireless network type | GSM/GPRS/EDGE/HSUPA/HSDPA/WC DMA | Required when accesstype=0 | |
tel | Mobile Number | | Optional | None |
bts | Access Base Station Information | Access Base Station Information, Table 1-2 Internal Parameter Description Non-CDMA format: mcc,mnc,lac,cellid,signal CDMA format: sid,nid,bid,lon,lat,signal, where lon,lat can be empty, format: sid,nid,bid,,,signal | Required when accesstype=0 | None |
nearbts | Surrounding Base Station Information (excluding access base station information) | Base station information 1|Base station information 2|Base station information 3….. | Optional | None |
mmac | mac information of the connected hotspot | mac,signal,ssid。 For example: f0:7d:68:9e:7d:18,-41,TPLink | Optional but strongly recommended to fill in | None |
macs | mac information in the wifi list | Single mac information is the same as mmac, macs are separated by "|". You must fill in 2 or more, and no more than 30 for normal positioning. Please do not include mobile wifi information. | Required when accesstype=1 | None |
output | Return data format type | Optional values: json,xml | Optional | json |
Parameter name | Parameter meaning | Is it mandatory |
mcc | Country code for mobile users, default value is 460 | Mandatory when cdma=0 |
mnc | Mobile Network Code, China Mobile: 0; China Unicom: 1 | Mandatory when cdma=0 |
lac | Location Area Code, range: 0-65535 | Mandatory when cdma=0 |
cellid | Base station cell ID, range: 0-65535, 0-268435455, where 0, 65535, 268435455 are not used, and when the cell ID is greater than 65535, it is a 3G base station | Mandatory when cdma=0 |
signal |
Signal strength, range: 0 to -113dbm. (If the obtained signal strength is positive, please convert it using the following formula: obtained positive signal strength * 2 – 113) | Mandatory when cdma=0 |
sid | cdma System Identification Code | Mandatory when cdma=1 |
nid | cdma network identifier | Mandatory when cdma=1 |
bid | cdma cell unique identifier | Mandatory when cdma=1 |
lon | cdma longitude value, read from the mobile platform interface | Optional |
lat | cdma latitude value, read from the mobile platform interface | Optional |
mac | mac address, for example: 00:0f:e2:4e:aa:3e | Mandatory when accesstype=1 |
ssid | Wireless network name | Mandatory when accesstype=1 |
Special note: In order to ensure the accuracy of your positioning results as much as possible, in all the above scenarios, in addition to the parameters that must be filled in, other parameters that can be obtained should also be passed in. For example: in the case of wifi access network, the corresponding base station information can also be passed in; in the case of mobile access network, the mac information (macs) in the wifi list can also be passed in.
Examples
Positioning scenario examples: According to the network access method, it can be divided into three positioning scenarios. The following provides corresponding examples for the three positioning scenarios.
When the connection method is wifi access, that is, when the accesstype parameter is 1:
http://sg-apilocate.opnavi.com/position?accesstype=1&imei=352315052834187&smac=E0:DB:55:
E4:C7:49&mmac=50:a7:2b:1e:56:58,-60,alibaba-inc&macs=4c:48:da:25:0b:11,-59,alibaba-inc|4c:4
8:da:25:1a:11,-77,alibaba-inc&serverip=10.2.166.4&key=<your key>
When the connection method is mobile access and the SIM card is a non-CDMA card, that is, the accesstype parameter is 0 and cdma=0:
https://sg-apilocate.opnavi.com/position?cdma=0&imsi=&accesstype=0&network=GPRS&bts=460%2C0%2C37335%2C545%2Cnull&platform=rest&key=<your key>
When the connection method is mobile access and the SIM card is a CDMA card, that is, the accesstype parameter is 0 and cdma=1:
http://sg-apilocate.opnavi.com/position?accesstype=0&imei=352315052834187&smac=E0:DB:55:E4:C7:49&cdma=1&bts=13824,1,1838,1674723,575739,-52&serverip=10.2.166.4&output=xml&key=<your key>
Response Parameters Description
Name | Description | Specification |
status | Return result status value | Value is 0 or 1, where 0 indicates failure and 1 indicates success |
info | Return status description | Return status description, when status is 0, info returns the error reason, otherwise returns 'OK' |
result | Positioning result list |
|
| type | Positioning type | 0: No positioning result obtained; Other numbers indicate: Normal positioning result obtained |
imei | Mobile phone imei number |
|
location | Positioning coordinates (latitude and longitude) |
|
radius | Positioning accuracy radius (unit: meters) |
|
desc | Location description |
|
country | Country | Optional return |
province | Province | Optional return |
city | City | Optional return |
citycode | City Code | Optional return |
adcode | Area Code | Optional return |
road | Road Name | Optional return |
poi | Locate nearby POI names | Optional return |