Batches
...
Batches API
Searches

List Searches

8min
list searches you can list the searches for a batch by making making a http get request to the /batches/batch id/searches/page endpoint (where batch id is the id of the batch to get searches for, and page is the page of searches to get) the /batches/batch id/searches/page endpoint returns the searches for a batch in pages of 1000 searches per page pages start at 1 you can find out how many pages a batch has by inspecting the searches page count field returned from the get batch https //docs trajectdata com/valueserp/batches api/batches/get endpoint value serp also provides two more endpoints to allow you to retrieve a download link for all searches in a batch, in either json or csv format list searches by page get get /batches/batch id/searches/page in the example below we list page 1 of the searches for the batch with id=123456 http https //api valueserp com/batches/123456/searches/1?api key=demo$ curl "https //api valueserp com/batches/123456/searches/1?api key=demo"const axios = require('axios'); const params = { api key 'demo' } axios get('https //api valueserp com/batches/123456/searches/1', { params }) then(response => { const apiresponse = response data; }) catch(error => { console log(error); });import requests params = { 'api key' 'demo' } api result = requests get('https //api valueserp com/batches/123456/searches/1', params) api response = api result json()\<?php $querystring = http build query(\[ 'api key' => 'demo', ]); $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/batches/123456/searches/1', $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); $json = curl exec($ch); curl close($ch); $api result = json decode($json, true); print r($api result); ?> value serp responds with the following json showing all the searches on page 1 of the batch { "request info" { "success" true }, "batch id" "123456", "searches page current" 1, "searches page count" 1, "searches" \[ { "q" "mcdonalds", "location" "united states", "search type" "images", "custom id" "mycustomid 001", "id" "abcdefghijklmnop" } ] } get json download links get get /batches/batch id/searches/json in the example below we retrieve download links for all searches for batch with id=123456 in json format http https //api valueserp com/batches/123456/searches/json?api key=demo$ curl "https //api valueserp com/batches/123456/searches/json?api key=demo"const axios = require('axios'); const params = { api key 'demo' } axios get('https //api valueserp com/batches/123456/searches/json', { params }) then(response => { const apiresponse = response data; }) catch(error => { console log(error); });import requests params = { 'api key' 'demo' } api result = requests get('https //api valueserp com/batches/123456/searches/json', params) api response = api result json()\<?php $querystring = http build query(\[ 'api key' => 'demo', ]); $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/batches/123456/searches/json', $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); $json = curl exec($ch); curl close($ch); $api result = json decode($json, true); print r($api result); ?> value serp responds with the following json detailing the total number of searches searches total count , the total number of pages searches page count and a json file download link for each page { "request info" { "success" true }, "batch id" "123456", "searches total count" 1, "searches page count" 1, "download links" { "pages" \[ "https //searches valueserp com/batch searches 123456 page 1 json" ] } } get csv download links get get /batches/batch id/searches/csv in the example below we retrieve download links for all searches for batch with id=123456 in csv format http https //api valueserp com/batches/123456/searches/csv?api key=demo$ curl "https //api valueserp com/batches/123456/searches/csv?api key=demo"const axios = require('axios'); const params = { api key 'demo' } axios get('https //api valueserp com/batches/123456/searches/csv', { params }) then(response => { const apiresponse = response data; }) catch(error => { console log(error); });import requests params = { 'api key' 'demo' } api result = requests get('https //api valueserp com/batches/123456/searches/csv', params) api response = api result json()\<?php $querystring = http build query(\[ 'api key' => 'demo', ]); $ch = curl init(sprintf('%s?%s', 'https //api valueserp com/batches/123456/searches/csv', $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); $json = curl exec($ch); curl close($ch); $api result = json decode($json, true); print r($api result); ?> value serp responds with the following json detailing the total number of searches searches total count , the total number of pages searches page count and a csv file download link for each page { "request info" { "success" true }, "batch id" "123456", "searches total count" 1, "searches page count" 1, "download links" { "pages" \[ "https //searches valueserp com/batch searches 123456 page 1 csv" ] } } next steps listing result sets https //docs trajectdata com/valueserp/batches api/results/list getting result sets https //docs trajectdata com/valueserp/batches api/results/get