Request
To receive a response about the location of a mobile device, send a POST request to the geolocation
resource. Pass the data in JSON format:
Yandex Locator processes the request data in the following order:
- Wi-Fi access points.
- Mobile network signals.
- IP address.
If Yandex Locator determines the location, it returns the response with the point's coordinates and the accuracy radius. Otherwise, you'll get a error message.
The Yandex Locator API has a limit on the number of requests per second (RPS): up to 1800. It's calculated as the sum of requests from the client and from the server.
Standard request
Pass the data about the mobile device and its environment in the json
request parameter.
Host: api.lbs.yandex.net
POST /geolocation
json={
"common": {
"version": "1.0",
"api_key": "ABM6WU0BAAAANfFuIQIAV1pUEYIBeogyUNvVbhNaJPWeM-AAAAAAAAAAAACRXgDsaYNpZWpBczn4Lq6QmkwK6g=="
},
"gsm_cells": [
{
"countrycode": 250,
"operatorid": 2,
"cellid": 197403650,
"lac": 9900,
"signal_strength": -80,
"age": 1000
}
],
"wifi_networks": [
{
"mac": "2CD02D814C80",
"signal_strength": -68,
"age": 500,
},
{
"mac": "E4AA5DE28CD0",
"signal_strength": -60,
"age": 500,
}
],
"ip": {
"address_v4": "95.108.173.231"
}
}
curl -X POST 'http://api.lbs.yandex.net/geolocation' -d 'json={"common": {"version": "1.0", "api_key": "ABM6WU0BAAAANfFuIQIAV1pUEYIBeogyUNvVbhNaJPWeM-AAAAAAAAAAAACRXgDsaYNpZWpBczn4Lq6QmkwK6g=="}, "gsm_cells": [ { "countrycode": 250, "operatorid": 2, "cellid": 197403650, "lac": 9900, "signal_strength": -80, "age": 1000} ], "wifi_networks": [ {"mac": "2CD02D814C80", "signal_strength": -68, "age": 500}, {"mac": "E4AA5DE28CD0", "signal_strength": -60, "age": 500} ], "ip": {"address_v4": "95.108.173.231"}}'
Keys
Object | Description | Required |
---|---|---|
common |
Request metadata. | Yes |
version |
Yandex Locator API Version: 1.0 . |
Yes |
api_key |
Yandex Locator API key . | Yes |
gsm_cells |
An array of objects, each of which describes one cell. The array must contain at least one object. | No |
countrycode |
Country code. | Yes |
operatorid |
Mobile network code. | Yes |
cellid |
Cell ID. | Yes |
lac |
Location code. | Yes |
signal_strength |
The signal strength measured at the location of the mobile device. A negative number expressed in decibel-milliwatts (dBm). The element is reserved for future use. | No |
age |
The time in milliseconds from the moment the data was received via the mobile device's software interface. The element is reserved for future use. | No |
wifi_networks |
An array of objects, each of which describes one Wi-Fi access point. At least one object is needed. | No |
mac |
The MAC address in character representation without separators. For example: 123456789ABC . |
Yes |
signal_strength |
The signal strength measured at the location of the mobile device. A negative number expressed in decibel-milliwatts (dBm). The element is reserved for future use. | No |
age |
The time in milliseconds from the moment the data was received via the mobile device's software interface. The element is reserved for future use. | No |
ip |
Contains the IP address. | No |
address_v4 |
The IP address of the mobile device assigned by the mobile internet carrier. If the IP address is missing or invalid, Yandex Locator uses the sender's address from the IP packet header. This address may be substituted by the proxy server the IP packet passed through. | Yes |
Request with compressed data
Compress the JSON with data using the gzip utility and pass it in the request. Specify the Content-Type: multipart/from-data
header and set any non-zero value to the gzip
parameter.
In the request of the multipart/from-data
type, include two parts:
gzip
: Indicator of the request with compressed data.json
: Parameter containing the compressed JSON data.
In each part of the request, specify the value of one parameter after the boundary
separator and the Content-Disposition
header that contains the parameter name. The parameter value must be separated from the preceding headers with an empty string.
Send a POST request to the geolocation
resource.
POST /geolocation?gzip=1
Host: api.lbs.yandex.net
Accept-Encoding: identity
Content-Type: multipart/form-data; boundary=YANDEXLOCATORBOUNDARY
Content-length: 538
--YANDEXLOCATORBOUNDARY
Content-Disposition: form-data; name="gzip"
1
--YANDEXLOCATORBOUNDARY
Content-Disposition: form-data; name="json"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
COMPRESSED DATA
--YANDEXLOCATORBOUNDARY--
curl -X POST 'http://api.lbs.yandex.net/geolocation?gzip=1' -H 'Content-Type: multipart/form-data' -F json=@data.json.gz
Keys
Header | Description |
---|---|
Accept-Encoding: identity |
Indicates the request contents should be accepted in any encoding. |
Content-Type: multipart/form-data; boundary=_separator_ |
The request type for passing files inside an HTTP request. The boundary separator is an arbitrary string of Latin letters and numbers. |
Content-length: _integer_ |
The length of the request in bytes starting from the second string after this header. |
Content-Disposition: form-data; name="_parameter_name_" |
The request prefix for passing the parameter declared in name . Preceded by a separator. The parameter value is specified after the child headers and an empty string. |
Content-Type: application/octet-stream |
Indicates the nested data is a file of an unspecified type. |
Content-Transfer-Encoding: binary |
Indicates the content is binary data. |
Description
Request metadata.
Required
Yes
Description
Yandex Locator API Version: 1.0
.
Required
Yes
Description
Yandex Locator API key .
Required
Yes
Description
An array of objects, each of which describes one cell. The array must contain at least one object.
Required
No
Description
Country code.
Required
Yes
Description
Mobile network code.
Required
Yes
Description
Cell ID.
Required
Yes
Description
Location code.
Required
Yes
Description
The signal strength measured at the location of the mobile device. A negative number expressed in decibel-milliwatts (dBm). The element is reserved for future use.
Required
No
Description
The time in milliseconds from the moment the data was received via the mobile device's software interface. The element is reserved for future use.
Required
No
Description
An array of objects, each of which describes one Wi-Fi access point. At least one object is needed.
Required
No
Description
The MAC address in character representation without separators. For example: 123456789ABC
.
Required
Yes
Description
Contains the IP address.
Required
No
Description
The IP address of the mobile device assigned by the mobile internet carrier.
If the IP address is missing or invalid, Yandex Locator uses the sender's address from the IP packet header. This address may be substituted by the proxy server the IP packet passed through.
Required
Yes
Indicates that request contents should be accepted in any encoding.
The request type for passing files inside an HTTP request.
The boundary
separator is an arbitrary string of Latin letters and numbers.
The length of the request in bytes starting from the second string after this header.
The request prefix for passing the parameter declared in name
. Preceded by a separator.
The parameter value is specified after the child headers and an empty string.
Indicates that the nested data is a file of an unspecified type.
Indicates the content is binary data.