On this page

    Geolocation API

    The MapTiler Geolocation API makes it possible to get approximate location of the incoming request, so you can localize your maps and applications. See the intro to IP geolocation to learn how geolocation works and what you can use it for.

    How to use the API

    • Directly from your web or backend applications.
    • Via the Geolocation API client library, which wraps the API calls in ready-made functions for easier use in JavaScript. Recommended if you don’t need a map.
    • With our complete map SDK JS. This is the best choice if you want the geolocation service plus a map. See related code examples for inspiration.

    Key

    You need a MapTiler API key to use this service. Get it here and learn how to protect it.


    IP Geolocation

    GET https://api.maptiler.com/geolocation/ip.json

    Obtain information about visitor's location based on IP address of the incoming request.

    Request

    You must include an API Key with every API request

    Query Parameters

    Parameters Type Description
    elevation
    boolean
    Include elevation (in meters) in the results.
    Default: false
    Request example
    
      https://api.maptiler.com/geolocation/ip.json?key=YOUR_MAPTILER_API_KEY

    Get your FREE API key in your MapTiler account.

    Responses

    Code Content Description
    200 application/json GeolocationResult
    403

    Key is missing, invalid or restricted

    GeolocationResult

    Property Type Description
    country
    string
    Name of the country
    Example: Switzerland
    country_code
    string
    Two-letter code of the country ISO 3166-1 alpha-2 codes
    Example: CH
    country_bounds
    array [= 4number]
    Bounds of the country in WGS84 degrees [west, south, east, north].
    Example: [5.95538,45.818852,10.490936,47.809357]
    country_languages
    array [string]
    Official country languages in ISO 639-1 format. ISO 639-1 codes
    Example: ["de","fr","it"]
    continent
    string
    Name of the continent
    Example: Europe
    continent_code
    string
    Two-letter code of the continent
    Example: EU
    eu
    boolean
    Indicated whether the country is part of the European Union.
    city
    string
    Name of the city
    Example: Zurich
    latitude
    number
    Latitude of the location
    Example: 47.36667
    longitude
    number
    Longitude of the location
    Example: 8.55
    postal
    string
    Postal code
    Example: 8000
    region
    string
    If known, the ISO 3166-2 name for the first level region. ISO 3166-2 codes
    Example: Zurich
    region_code
    string
    If known, the ISO 3166-2 code for the first level region. ISO 3166-2 codes
    Example: ZH
    timezone
    string
    Name of the timezone
    Example: Europe/Zurich
    elevation
    number
    Elevation of the location in meters
    Example: 433

    GeolocationResult example

    
        {
      "country": "Switzerland",
      "country_code": "CH",
      "country_bounds": [5.95538, 45.818852, 10.490936, 47.809357],
      "country_languages": ["de", "fr", "it"],
      "continent": "Europe",
      "continent_code": "EU",
      "eu": false,
      "city": "Zurich",
      "latitude": 47.36667,
      "longitude": 8.55,
      "postal": "8000",
      "region": "Zurich",
      "region_code": "ZH",
      "timezone": "Europe/Zurich",
      "elevation": 433
    }
      
    Using the OpenAPI Specification?
    Get the openapi.yaml

    Was this helpful?

    MapTiler API
    Geolocation API
    Geolocation API