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:

  1. Wi-Fi access points.
  2. Mobile network signals.
  3. 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:

  1. gzip: Indicator of the request with compressed data.
  2. 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.
Previous