How to determine the user's location by IP address

Description

The API endpoint returns the IATA code, the name of the nearest city to the user and additional information.

Request

http://www.travelpayouts.com/whereami?locale=en&callback=useriata&ip=62.105.128.0

Request parameters

  • locale — language in which the name of the city is returned (available in, rue, de, fr, it, pl, th);
  • callback — specifies the name of the function that contains the response to the request (required parameter);
  • ip — IP address of the user (If the address is not transferred, the system determines the IP from the header of the request).

Response example

{"city":{"iata":"BJS","name":"Пекин"},"country":{"iata":"CN","name":"Китай"},"coordinates":{"lat":39.904214,"lon":116.407413},"currency":"CNY","timezone":"Asia/Shanghai"}

Response parameters

  • city.iata — the IATA code of the city
  • city.name — the city name where the user is located
  • country.iata — the IATA code of the country
  • country.name — the country name
  • coordinates — airport coordinates
  • currency — the country national currency
  • timezone — the city timezone

Was this article helpful?

Have more questions? Submit a request