Search Stores Nearby a User's Device Location

How to search stores nearby a user’s device based on its ip address

  1. Overview
  2. Optional parameters
  3. Stores nearby Geolocation example
  4. Response
  5. Example using your IP Address
  6. Usage limits

Minimum acceptable accuracy
Stores are retrieved only for an accuracy of 20km or less.

Overview

This API endpoint allows you to retrieve the stores nearby an ip location. Stores are returned only if a relevant ip location is found.

Minimum acceptable accuracy
For narrowing down the nearby stores, please refer to the search API as this endpoint accepts the same parameters (e.g. radius).

You can query the API using your public or 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

        https://api.woosmap.com/geolocation/stores/?private_key={PRIVATE_API_KEY}&radius=10000&&limit=10

    

limit

In addition to optional parameters from Search API you can specify a limit value to limit number of assets to retrieve from an IP location (integer value)

cc_format

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

Available cc_format values are alpha2 or alpha3.

Stores nearby Geolocation example

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

Stores Geolocation call
        https://api.woosmap.com/geolocation/stores
  ?ip_address=173.79.254.254
  &limit=1
  &private_key=YOUR_PRIVATE_API_KEY
    
        curl -L -X GET 'https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1'

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

fetch("https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1", 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: 'https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1',
  headers: { }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});


    
        import requests

url = "https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1"

payload={}
headers = {}

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

print(response.text)


    
        OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1")
  .method("GET", body)
  .build();
Response response = client.newCall(request).execute();

    
        require "uri"
require "net/http"

url = URI("https://api.woosmap.com/geolocation/stores?private_key=YOUR_PRIVATE_API_KEY&ip_address=173.79.254.254&limit=1")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)

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


    

Response

The Response is a formated JSON containing the keys: country_code, country_name, continent, city, region_state, postal_code, timezone, raw_offset, dst_offset. See the Get Location endpoint documentation for more details on those keys.

According to IP data relevance, JSON can contain the device location and nearby stores (based on your query)

Geolocation Stores Response
JSON
        {
  "country_code": "US",
  "country_name": "United States",
  "continent": "North America",
  "latitude": 38.719,
  "longitude": -77.1067,
  "accuracy": 5,
  "viewport":
    {
      "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",
  "stores":
    {
      "type": "FeatureCollection",
      "features":
        [
          {
            "type": "Feature",
            "properties":
              {
                "store_id": "STORE_ID_123456",
                "name": "My Cool Store",
                "contact":
                  {
                    "email": "[email protected]",
                    "phone": "+44 20 7693 4000",
                    "website": "https://www.woosmap.com",
                  },
                "address":
                  {
                    "lines": ["Building Centre", "26 Store Street"],
                    "country_code": "UK",
                    "city": "London",
                    "zipcode": "WC1E 7BT",
                  },
                "user_properties":
                  { "some_user_properties": "associated user value" },
                "tags": ["wifi", "covered_parking"],
                "types": ["drive", "click_and_collect"],
                "last_updated": "2024-03-20T15:14:51.067524+00:00",
                "distance": 0,
                "open":
                  {
                    "open_now": true,
                    "open_hours": [{ "end": "22:00", "start": "08:30" }],
                    "week_day": 3,
                    "current_slice": { "end": "22:00", "start": "08:30" },
                  },
                "weekly_opening":
                  {
                    "1": { "hours": [], "isSpecial": false },
                    "2":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "3":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "4":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "5":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "6":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "7":
                      {
                        "hours": [{ "end": "22:00", "start": "08:30" }],
                        "isSpecial": false,
                      },
                    "timezone": "Europe/London",
                  },
                "opening_hours":
                  {
                    "usual":
                      {
                        "1": [],
                        "default": [{ "end": "22:00", "start": "08:30" }],
                      },
                    "special":
                      { "2015-02-07": [{ "end": "23:00", "start": "08:00" }] },
                    "timezone": "Europe/London",
                  },
              },
            "geometry": { "type": "Point", "coordinates": [-77.1067, 38.719] },
          },
        ],
      "pagination": { "page": 1, "pageCount": 2 },
    },
}

    

Example using your IP Address

Usage limits

The following usage limits are in place for the /stores 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