Response

In response to the request, Yandex Locator returns:

Location response

Response example

 {
   "position": {
     "latitude": 55.743675,
     "longitude": 37.5646301,
     "altitude": 0.0,
     "precision": 701.71643,
     "altitude_precision": 30.0,
     "type": "gsm"
   }
 }

Keys

Object

Description

position

Contains the point's coordinates in the WGS-84 system and other location data.

latitude

Latitude in degrees with an accuracy of seven decimal places.

longitude

Longitude in degrees with an accuracy of seven decimal places.

altitude

Height above the world ocean's surface.

precision

Accuracy radius in meters.
100,000 means Yandex Locator couldn't determine the location accurately.

altitude_precision

The maximum deviation from the specified height in meters.

type

The method used for determining the location:

  • gsm: Using mobile network cells.
  • wifi: Using Wi-Fi access points.
  • ip: By the IP address.

Error message

If Yandex Locator can't process the request, you receive an error message:

 {
     "error": {
         "code": _code_,
         "message": "_message text_"
     }
 }
  • 2: Internal service error.
  • 6: Couldn't determine location.
  • 7: Invalid JSON structure.
  • 8: Invalid access key.

Keys

Object

Description

code

Error code:

  • 2: Internal service error.
  • 6: Couldn't determine location.
  • 7: Invalid JSON structure.
  • 8: Invalid access key.

message

Error message text.

Examples of error messages

  1. Couldn't determine location.

    {
        "error": {
           "code": 6,
           "message": "Location not found"
        }
    }
    

    Information about the cells, Wi-Fi access points, and subnets that own the IP address is missing in the service. This error also occurs if the data format is invalid.

  2. Couldn't process JSON.

    {
       "error": {
           "code": 7,
           "message": "JSON request is invalid"
       }
    }
    

    The passed JSON array has an invalid structure. For example, some required elements, brackets, or closing tags may be missing.

  3. Invalid access key.

    {
       "error": {
           "code": 8,
           "message": "invalid api_key"
       }
    }
    

Make sure that the key specified in the request is valid.