Batches
...
Batches
Create Batch
7 min
create batch create a batch to run up to 15,000 searches (100 when adding searches with include html=true set) on a schedule you can have up to 10,000 batches set up on your scale serp account at any one time batches are created by making an http post to the /batches endpoint post parameters can be either supplied as x www form urlencoded parameters or by post'ing a json object to the /batches endpoint using include html=true in batches when adding searches with include html=true to a batch the maximum number of searches per batch is 100 (rather than 15,000) because including the html within the response makes the batch result sets much larger the limit is in place to ensure result set files are of a manageable size if you have need to run a large number of searches all with include html=true then simply split the searches across multiple 100 search batches example post post /batches let's start with a simple example; we'll create a batch that is set to run every day at 9am and 5pm we'll use the notification email parameter to specify an email address to send notifications to (when the batch completes), the notification as csv parameter to request the batch results be delivered in csv format and the destination ids parameter to request that the result sets generated by running the batch be uploaded to the specified destination id of "abcdefg" $ curl "https //api scaleserp com/batches?api key=demo" \\ d name="my first batch" \\ d enabled=true \\ d schedule type="daily" \\ d priority="normal" \\ d schedule hours="9,17" \\ d destination ids="abcdefg" \\ d notification email="john smith\@example com" \\ d notification as csv=trueconst axios = require('axios'); const body = { name 'my first batch', enabled true, schedule type 'daily', priority 'normal', schedule hours \[9,17], destination ids \[ 'abcdefg' ], notification email 'john smith\@example com', notification as csv true } axios post('https //api scaleserp com/batches?api key=demo', body) then(response => { const apiresponse = response data; console log('batch created ' + json stringify(apiresponse, 0, 2)); }) catch(error => { console log(error); });import requests body = { "name" "my first batch", "enabled" true, "schedule type" "daily", "priority" "normal", "schedule hours" \[9,17], "destination ids" \[ "abcdefg" ], "notification email" "john smith\@example com", "notification as csv" true } api result = requests post('https //api scaleserp com/batches?api key=demo', json=body) api response = api result json() print "batch created ", json dumps(api response)\<?php $body = http build query(\[ "name" => "my first batch", "enabled" => true, "schedule type" => "daily", "priority" => "normal", "schedule hours" => "9,17", "destination ids" => "abcdefg", "notification email" => "john smith\@example com", "notification as csv" => true ]); $ch = curl init('https //api scaleserp com/batches?api key=demo'); 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); curl setopt($ch, curlopt customrequest, "post"); curl setopt($ch, curlopt postfields, $body); $json = curl exec($ch); curl close($ch); $api result = json decode($json, true); print r($api result); echo "batch created", php eol; ?> scale serp responds with the following json confirming the batch has been successfully created note the batch id , you'll use the batch id in subsequent calls to update https //docs trajectdata com/scaleserp/batches api/batches/update , delete https //docs trajectdata com/scaleserp/batches api/batches/delete and add searches https //docs trajectdata com/scaleserp/batches api/searches/create to the batch { "request info" { "success" true }, "batch" { "id" "f994420d", "created at" "2020 01 01 00 00 000z", "name" "my first batch", "schedule type" "daily", "priority" "normal", "schedule hours" \[ 9, 17 ], "destination ids" \[ "abcdefg" ], "enabled" true, "status" "idle", "search total count" 0, "search page count" 0, "next result set id" 1, "results count" 0, "notification email" "john smith\@example com", "notification as json" false, "notification as csv" true, "search type" "mixed", "search type locked" false } } scheduling batches batches can be scheduled on a monthly, weekly or daily basis you can also set a batch to be started manually, either via the scale serp dashboard https //app scaleserp com/batches or the start batch api https //docs trajectdata com/scaleserp/batches api/batches/start a batches' schedule is defined by the schedule type parameter the values of schedule type , and other associated parameters are shown below batch schedules are executed in the timezone set up on your profile https //app scaleserp com/profile true falsefalse left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type batch parameters post post /batches the following parameters can be used when creating a batch the api key parameter should be supplied as a querystring parameter on the request url parameters other than api key should be supplied in either x www form urlencoded or json format, in the request body true falsefalse left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type false left unhandled content type next steps update batches https //docs trajectdata com/scaleserp/batches api/batches/update