Response

In response to the request, Yandex Locator returns:

Location response

Response example

<?xml version="1.0" encoding="UTF-8"?>
<ya_lbs_response>
  <position>
    <latitude>55.7351526</latitude>
    <longitude>37.5951196</longitude>
    <altitude>0.0</altitude>
    <precision>826.319232</precision>
    <altitude_precision>30.0</altitude_precision>
    <type>gsm</type>
  </position>
</ya_lbs_response>

Elements

Element

Description

ya_lbs_response

Root element.

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:

<?xml version="1.0" encoding="utf-8"?>
<error code="code">error text</error>

Elements

Element

Description

error

Error message code.

code

Error code:

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

Examples of error messages

  1. Couldn't determine location.

    <?xml version="1.0" encoding="utf-8"?>
    <error code="6">Location not found</error>
    

    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 the XML structure.

    <?xml version="1.0" encoding="utf-8"?>
    <error code="7">XML request is invalid</error>
    

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

  3. Invalid access key.

     <?xml version="1.0" encoding="utf-8"?>
     <error code="8">invalid api_key</error>
    
    

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

Previous