Core APIs
Search API
Introduction
4min
overview value serp executes search requests in real time returning clean, structured json html or csv results you can achieve fine grained control over your search query using the search parameters https //docs trajectdata com/valueserp/search api/searches/common making a request get get /search performing a search is as simple as making a get http request to the value serp search endpoint the only required parameters are api key ( sign up https //app valueserp com/signup for free to get an api key) and q (your search query) for example, to search for the phrase pizza the value serp search request would be http https //api valueserp com/search?api key=demo\&q=pizza$ curl get https //api valueserp com/search \\ d api key="demo" \\ d q="pizza"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "pizza" } // 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' 'pizza' } \# 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' => 'pizza' ]); \# 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; to view value serp json results clearly in your browser we recommend these extensions for chrome and firefox lets say we want to refine our query to search for pizza within london, uk here's how we could use the value serp location parameter to achieve just that http https //api valueserp com/search?api key=demo\&q=pizza\&location=london,england,united kingdom$ curl get https //api valueserp com/search \\ d api key="demo" \\ d q="pizza" \\ d location="london,england,united kingdom"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "pizza", location "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' 'pizza', 'location' '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' => 'pizza', 'location' => '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; now lets try the same search but in paris, france when we update the location parameter note how value serp automatically changes the google domain parameter to google fr and the gl (country) and hl (language) parameters to hl=fr (so you see localized results exactly as a human user in paris would) http https //api valueserp com/search?api key=demo\&q=pizza\&location=paris,ile de france,france$ curl get https //api valueserp com/search \\ d api key="demo" \\ d q="pizza" \\ d location="paris,ile de france,france"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "pizza", location "paris,ile de france,france" } // 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' 'pizza', 'location' 'paris,ile de france,france' } \# 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' => 'pizza', 'location' => 'paris,ile de france,france' ]); \# 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; now lets take a look at how to paginate through results using the page and num parameters page determines the page number of the results (starting from 1) and num determines the number of results to show per page if we wanted to show the 2nd page of results, based on 10 results per page, our query would be http https //api valueserp com/search?api key=demo\&q=pizza\&page=2\&num=10$ curl get https //api valueserp com/search \\ d api key="demo" \\ d q="pizza" \\ d page="2" \\ d num="10"const axios = require('axios'); // set up the request parameters const params = { api key "demo", q "pizza", page "2", num "10" } // 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' 'pizza', 'page' '2', 'num' '10' } \# 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' => 'pizza', 'page' => '2', 'num' => '10' ]); \# 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;