DevHub API Documentation
  • Introduction
  • Authentication
  • Errors
  • Getting started guides
    • Business-focused Sites
    • Location-focused Sites
    • Location pages and store locator with custom theme
    • Site publishing with site builder access
  • Code examples
    • Python
    • PHP
    • Perl
  • Best practices
    • Our unique IDs, versus yours
    • State and country codes
  • Core Resources
    • Sites
    • Businesses
    • Locations
    • Domains
    • Proxies
  • Content Resources
    • Pages
    • Content
    • Images
    • Files
    • Modules
    • Plugins
    • Themes
  • Logging and analytics
    • Analytics
    • Contact Logs
  • Single Sign On (SSO)
    • Introduction
    • Assigning a site's user
  • Live Preview API
    • What is the Live Preview API?
  • Advanced
    • Domain aliases
    • Language codes
    • Projects
    • Site Check
    • Traces
    • Webmail
  • Local Storage API
    • What is the Local Storage API?
  • Headless CMS
    • Locations search
  • Visitor Localization SDK
    • Visitor Localization SDK
Powered by GitBook
On this page
  • Search locations
  • Basic examples
  • Parameters
  • Response
  • Additional examples

Was this helpful?

  1. Headless CMS

Locations search

Query and search locations using the same technology that powers our Location Finder technology

Search locations

Search locations using a geo-search query (City, State, Postal code) or using specific latitude and longitude coordinates.

Locations are sorted by distance from the searched location.

GET /_api/locations_search/

Basic examples

Search with geo query - search string

GET /_api/locations_search/?near_location=Seattle,%20WA

Search with geo postal code query

GET /_api/locations_search/?near_location=98121

Search with latitude/longitude coordinates

GET /_api/locations_search/?near_lat=39.8281&near_lon=-98.5795

Parameters

Name
Type
Description

near_location

string

Geographic search query. Can take any input that could be passed to Google Geocoding including city, state, full address or postal code

near_lat

float

Example: 39.8281

Used in combination with near_lon

near_lon

float

Example: -98.5795

Used in combination with near_lat

limit

integer

Number of locations to return

threshold

integer

Distance in distance_unit (miles/km) to restrict location search results

distance_unit

string

miles (default) or km

postal_code_match_type

string

Matching to location assigned postal code territories

Options: - only: This will only return locations that have postal codes assigned that match - first: This will return matching locations, but if no locations are assigned the postal code then normal geo-distance searched results will be returned

prefix

string

Passed as prefix=true - Enables canadian postal code prefix searching.

Used in combination with postal_code_match_type Example: L0P 1B0 would match territory assignment in DevHub of L0P

Response

Locations are returned within objects. If no locations are matched, objects will be an empty list.

{
    "meta": {
        "total_count": 25
        ...
    },
    "objects": [
        {...Location object...},
        {...Location object...},
    ]
}

The response will also contain distance details for each location and distance context.

In the resulting response meta we will add the latitude and longitude of the searched point for reference.

{
    "meta": {
        "lat": 47.6062095,
        "lon": -122.3320708,
        ...
    }
}

In each of the the resulting Location objects, we add distance (in miles or km depending on distance_unit).

"objects": [{
    "id": 123456,
    "location_name": "Belltown",
    ...
    "distance": 996.79
}]

Additional examples

See if a postal code is assigned to any location

GET /_api/locations_search/?
    near_location=98121&
    postal_code_match_type=only&
    limit=1
PreviousWhat is the Local Storage API?NextVisitor Localization SDK

Last updated 13 days ago

Was this helpful?

For list of attributes returned for each location, see

Location model