Core APIs
Locations API

Overview

5min
locations api overview get get /locations the value serp locations api allows you to search for value serp supported google search locations you can supply the full name returned by the locations api as the location parameter in a search api https //docs trajectdata com/valueserp/search api query to retrieve search results localized to that location the locations api is free of charge there is no charge for usage of the locations api and requests to it will not decrement your monthly search credits however, to guarantee quality of service to all customers, we do apply a rate limit of 120 requests per minute to search for the location london the value serp locations api request would be http https //api valueserp com/locations?api key=demo\&q=london$ curl get https //api valueserp com/locations \\ d api key="demo" \\ d q="london"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "london" } // make the http get request to value serp axios get('https //api valueserp com/locations', { params }) then(response => { // print the json response from value serp console log(json stringify(response data, 0, 2)); }) catch(error => { // catch and print the error console log(error); })import requests import json \# set up the request parameters params = { 'api key' 'demo', 'q' 'london' } \# make the http get request to value serp api result = requests get('https //api valueserp com/locations', params) \# print the json response from value serp print(json dumps(api result json()))# set up the request parameters $querystring = http build query(\[ 'api key' => 'demo', 'q' => 'london' ]); \# make the http get request to value serp $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/locations', $querystring)); curl setopt($ch, curlopt returntransfer, true); curl setopt($ch, curlopt followlocation, true); \# the following options are required if you're using an outdated openssl version \# more details https //www openssl org/blog/blog/2021/09/13/letsencryptrootcertexpire/ curl setopt($ch, curlopt ssl verifyhost, false); curl setopt($ch, curlopt ssl verifypeer, false); curl setopt($ch, curlopt timeout, 180); $api result = curl exec($ch); curl close($ch); \# print the json response from value serp echo $api result; to view value serp json results clearly in your browser we recommend these extensions for chrome and firefox here are the results from the request above, note that the locations array contains the value serp supported locations matching the query supplied in the q parameter { "request info" { "success" true }, "locations" \[ { "id" 9041106, "name" "greater london", "type" "county", "full name" "greater london,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 20800000 }, { "id" 1006886, "name" "london", "type" "city", "full name" "london,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 19900000 }, { "id" 9041110, "name" "city of london", "type" "county", "full name" "city of london,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 19900000 }, { "id" 1002316, "name" "london borough of lambeth", "type" "municipality", "full name" "london borough of lambeth,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 983000 }, { "id" 9057243, "name" "new london county", "type" "county", "full name" "new london county,connecticut,united states", "parent id" 21139, "country code" "us", "reach" 434000 }, { "id" 1002325, "name" "london", "type" "city", "full name" "london,ontario,canada", "parent id" 20121, "country code" "ca", "reach" 418000 }, { "id" 1007284, "name" "londonderry", "type" "city", "full name" "londonderry,northern ireland,united kingdom", "parent id" 20341, "country code" "gb", "reach" 192000 }, { "id" 9041230, "name" "london stansted airport", "type" "airport", "full name" "london stansted airport,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 153000 }, { "id" 1017821, "name" "london", "type" "city", "full name" "london,kentucky,united states", "parent id" 21150, "country code" "us", "reach" 144000 }, { "id" 1014779, "name" "new london", "type" "city", "full name" "new london,connecticut,united states", "parent id" 21139, "country code" "us", "reach" 136000 } ] } lets say we want to refine our location query to search for locations matching london that are cities within great britain to do that we use the type and country code parameters http https //api valueserp com/locations?api key=demo\&q=london\&type=city\&country code=gb$ curl get https //api valueserp com/locations \\ d api key="demo" \\ d q="london" \\ d type="city" \\ d country code="gb"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "london", type "city", country code "gb" } // make the http get request to value serp axios get('https //api valueserp com/locations', { params }) then(response => { // print the json response from value serp console log(json stringify(response data, 0, 2)); }) catch(error => { // catch and print the error console log(error); })import requests import json \# set up the request parameters params = { 'api key' 'demo', 'q' 'london', 'type' 'city', 'country code' 'gb' } \# make the http get request to value serp api result = requests get('https //api valueserp com/locations', params) \# print the json response from value serp print(json dumps(api result json()))# set up the request parameters $querystring = http build query(\[ 'api key' => 'demo', 'q' => 'london', 'type' => 'city', 'country code' => 'gb' ]); \# make the http get request to value serp $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/locations', $querystring)); curl setopt($ch, curlopt returntransfer, true); curl setopt($ch, curlopt followlocation, true); \# the following options are required if you're using an outdated openssl version \# more details https //www openssl org/blog/blog/2021/09/13/letsencryptrootcertexpire/ curl setopt($ch, curlopt ssl verifyhost, false); curl setopt($ch, curlopt ssl verifypeer, false); curl setopt($ch, curlopt timeout, 180); $api result = curl exec($ch); curl close($ch); \# print the json response from value serp echo $api result; note that the results now reflect just cities within the gb country code { "request info" { "success" true }, "locations" \[ { "id" 1006886, "name" "london", "type" "city", "full name" "london,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 19900000 }, { "id" 1007284, "name" "londonderry", "type" "city", "full name" "londonderry,northern ireland,united kingdom", "parent id" 20341, "country code" "gb", "reach" 192000 }, { "id" 1006887, "name" "london colney", "type" "city", "full name" "london colney,england,united kingdom", "parent id" 20339, "country code" "gb", "reach" 113000 } ] } running a search specifying a location you can pass the fully qualified ( full name ) location name into the location parameter of a search api request to retrieve search results from that location in the example below we are passing the location of greater london,england,united kingdom , as retrieved from the full name property in the locations api response, in the search api location parameter http https //api valueserp com/search?api key=demo\&q=coffee\&location=greater london,england,united kingdom$ curl get https //api valueserp com/search \\ d api key="demo" \\ d q="coffee" \\ d location="greater london,england,united kingdom"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "coffee", location "greater london,england,united kingdom" } // make the http get request to value serp axios get('https //api valueserp com/search', { params }) then(response => { // print the json response from value serp console log(json stringify(response data, 0, 2)); }) catch(error => { // catch and print the error console log(error); })import requests import json \# set up the request parameters params = { 'api key' 'demo', 'q' 'coffee', 'location' 'greater london,england,united kingdom' } \# make the http get request to value serp api result = requests get('https //api valueserp com/search', params) \# print the json response from value serp print(json dumps(api result json()))# set up the request parameters $querystring = http build query(\[ 'api key' => 'demo', 'q' => 'coffee', 'location' => 'greater london,england,united kingdom' ]); \# make the http get request to value serp $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/search', $querystring)); curl setopt($ch, curlopt returntransfer, true); curl setopt($ch, curlopt followlocation, true); \# the following options are required if you're using an outdated openssl version \# more details https //www openssl org/blog/blog/2021/09/13/letsencryptrootcertexpire/ curl setopt($ch, curlopt ssl verifyhost, false); curl setopt($ch, curlopt ssl verifypeer, false); curl setopt($ch, curlopt timeout, 180); $api result = curl exec($ch); curl close($ch); \# print the json response from value serp echo $api result;