/v2/autocomplete/locations| 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 |
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.
| 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. |
The type field in the response indicates the geographic level:
| Value | Level |
|---|---|
| 1 | Country |
| 2 | Region / state |
| 3 | Municipality |
| 4 | City |
apiToken string x-api-token string query string Required limit integer "companies""people"200 Successful ResponsecountryCode string Required filterCode string Required name string Required parentCode string Required parentName string Required "1-country""2-region""3-municipality""4-city"400 Bad Requestdetail enum Required "Conflicting API tokens provided in query parameters and headers"402 Payment Requireddetail enum Required "Insufficient credits"403 Forbiddendetail enum Required "API token should be provided in headers or query parameters""Current API token is not registered in our database"404 Not found422 Validation Errormsg string Required type string Required input any