post /v2/autocomplete/locations

Autocomplete locations

Auto complete the location search
Endpoint POST /v2/autocomplete/locations
Credit cost 0.1 credits / call
Response Synchronous — up to 15 results
When to use Power a type-ahead input for region/city location filters

Quickstart#

Location filters use filterCode values rather than plain country codes. Use this endpoint to resolve a user's typed location into the correct filter codes for primaryLocations.includeLocations.

curl -X POST "https://api.ocean.io/v2/autocomplete/locations" \
  -H "X-Api-Token: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "londo",
    "locationType": "companies",
    "limit": 5
  }'
import requests

response = requests.post(
    'https://api.ocean.io/v2/autocomplete/locations',
    headers={'X-Api-Token': 'YOUR_API_TOKEN'},
    json={'query': 'londo', 'locationType': 'companies', 'limit': 5},
)
data = response.json()
const response = await fetch('https://api.ocean.io/v2/autocomplete/locations', {
  method: 'POST',
  headers: { 'X-Api-Token': 'YOUR_API_TOKEN', 'Content-Type': 'application/json' },
  body: JSON.stringify({ query: 'londo', locationType: 'companies', limit: 5 }),
});
const data = await response.json();

Example response:

{
  "locations": [
    {
      "filterCode": "gb-ENG-LND",
      "name": "London",
      "countryCode": "gb",
      "parentCode": "gb-ENG",
      "parentName": "England",
      "type": 4
    }
  ]
}

Use filterCode in companiesFilters.primaryLocations.includeLocations or peopleFilters.locations.includeLocations.


Parameters#

Parameter Type Description
query string Required. Beginning of the location name.
locationType string "companies" (default) or "people". Use "people" to include metro areas like "San Francisco Bay Area" that appear in people profiles but not company HQ data.
limit integer Optional. Max results to return. Default 5, maximum 15.

Location types#

The type field in the response indicates the geographic level:

Value Level
1 Country
2 Region / state
3 Municipality
4 City

Authorizations

apiToken string
x-api-token string

Body application/json

query string Required
Beginning of the location
limit integer
Number of locations to return. Default is 5 if not specified, maximum is 15.
Type of entities to search locations for. Use 'people' to include non-standard locations like 'San Francisco Bay Area'.
enum
"companies""people"

Responses

200 Successful Response
Array of found locations with metadata. Returns empty array if no results
Array of Location
countryCode string Required
ISO country code
filterCode string Required
Code used for filtering locations
name string Required
English name of the location
parentCode string Required
Code of the parent location
parentName string Required
Name of the parent location
Type of location: 1-country, 2-region, 3-municipality, 4-city
enum
"1-country""2-region""3-municipality""4-city"
400 Bad Request
detail enum Required
"Conflicting API tokens provided in query parameters and headers"
402 Payment Required
detail enum Required
"Insufficient credits"
403 Forbidden
detail enum Required
"API token should be provided in headers or query parameters""Current API token is not registered in our database"
404 Not found
422 Validation Error
Array of ValidationError
Array of string | integer
string | integer
msg string Required
type string Required
input any
object