Get User's Device Location

How to get location of a user’s device from its ip address

  1. Overview
  2. Optional parameters
  3. Geolocation example
  4. Response
  5. Your IP address Example
  6. Usage limits


Woosmap Geolocation API can provide the location of your users thanks to IP address of their devices. You can query the API using a public or a private key according to your use case and calls origins.

Client-side requests

For client-side requests, use your public key (parameter key) related to your project. The IP address to geocode is the public IP from the user device.

Server-side requests

For server-side requests, get the position of a specific ip address using a private_key in your requests and parameter ip_address to geolocate.

Optional parameters{PRIVATE_API_KEY}&cc_format=alpha2



To specify the country code format returned in the response. Default is alpha2.

Available cc_format values are alpha2 or alpha3.

Geolocation example

The following example requests the geolocation of a specific IP address on the server-side:

Geolocation call
        curl -L -X GET ''

        var requestOptions = {
  method: 'GET',
  redirect: 'follow'

fetch("", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

        var axios = require('axios');

var config = {
  method: 'get',
  url: '',
  headers: { }

.then(function (response) {
.catch(function (error) {

        import requests

url = ""

headers = {}

response = requests.request("GET", url, headers=headers, data=payload)


        OkHttpClient client = new OkHttpClient().newBuilder()
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .method("GET", body)
Response response = client.newCall(request).execute();

        require "uri"
require "net/http"

url = URI("")

https =, url.port)
https.use_ssl = true

request =

response = https.request(request)
puts response.read_body



For a provided location, the response is a formatted JSON containing the keys:

country_code ISO 3166-1 Alpha-2 or Alpha-3 compatible country code
country_name country name (string value)
continent continent name (string value)
region_state region name when available (string value)
city city name (string value) when available
postal_code a postal code close to the user’s location, when available
latitude longitude approximate latitude and longitude of the geographical area associated with the IP address
accuracy radius in kilometers around the specified location where the IP address is likely to be
viewport geographic bounds (northeast latlng and southwest latlng) build from latitude, longitude and accuracy values, to help center a map
timezone the time zone associated with location, as specified by the IANA Time Zone Database
raw_offset the offset from the Coordinated Universal Time (UTC) in seconds
dst_offset the Daylight Saving Time (DST) offset in seconds

According to IP data relevance and accuracy some keys may eventually not be provided.

Geolocation Position Response
  "country_code": "US",
  "country_name": "United States",
  "continent": "North America",
  "latitude": 38.719,
  "longitude": -77.1067,
  "accuracy": 5,
      "northeast": { "lat": 38.763915764205976, "lng": -77.0491321464058 },
      "southwest": { "lat": 38.674084235794034, "lng": -77.16426785359421 },
  "city": "Alexandria",
  "region_state": "Virginia",
  "postal_code": "22309",
  "timezone": "America/New_York",


Your IP address Example

Here is a sample of a Geolocation API call using Javascript. The fetched location is used to display a map.

Usage limits

The following usage limits are in place for the /position endpoint of Geolocation API:

If a Public Key is used

If a Private Key is used

Was this article helpful?
Have more questions? Submit a request