Retry Failed Items
curl --request POST \
--url https://api.spidra.io/api/batch/scrape/{batchId}/retry \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.spidra.io/api/batch/scrape/{batchId}/retry"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.spidra.io/api/batch/scrape/{batchId}/retry', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.spidra.io/api/batch/scrape/{batchId}/retry",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.spidra.io/api/batch/scrape/{batchId}/retry"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.spidra.io/api/batch/scrape/{batchId}/retry")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.spidra.io/api/batch/scrape/{batchId}/retry")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": "queued",
"retriedCount": 3
}{
"status": "error",
"message": "No failed items to retry.",
"code": "NO_FAILED_ITEMS"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}Scrape Endpoints
Retry Failed Batch Scrapes
Re-queue only the failed scrapes in a completed batch
POST
/
batch
/
scrape
/
{batchId}
/
retry
Retry Failed Items
curl --request POST \
--url https://api.spidra.io/api/batch/scrape/{batchId}/retry \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.spidra.io/api/batch/scrape/{batchId}/retry"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.spidra.io/api/batch/scrape/{batchId}/retry', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.spidra.io/api/batch/scrape/{batchId}/retry",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.spidra.io/api/batch/scrape/{batchId}/retry"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.spidra.io/api/batch/scrape/{batchId}/retry")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.spidra.io/api/batch/scrape/{batchId}/retry")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"status": "queued",
"retriedCount": 3
}{
"status": "error",
"message": "No failed items to retry.",
"code": "NO_FAILED_ITEMS"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}{
"status": "error",
"message": "<string>"
}After a batch completes with some failures, retry only the failed scrapes. Successful items are never touched. Fresh credits are reserved for the retry, and the batch status resets to
After a successful retry:
No failed items:
running.
curl -X POST https://api.spidra.io/api/batch/scrape/YOUR_BATCH_ID/retry \
-H "Authorization: Bearer YOUR_API_KEY"
const res = await fetch(
`https://api.spidra.io/api/batch/scrape/${batchId}/retry`,
{
method: "POST",
headers: { Authorization: "Bearer YOUR_API_KEY" },
}
);
const { retriedCount } = await res.json();
console.log(`${retriedCount} items re-queued`);
// Poll the same batchId until it completes again
import requests
resp = requests.post(
f"https://api.spidra.io/api/batch/scrape/{batch_id}/retry",
headers={"Authorization": "Bearer YOUR_API_KEY"},
)
print(f"{resp.json()['retriedCount']} items re-queued")
Full Retry Pattern
async function runWithRetry(urls, options, maxAttempts = 3) {
// Submit the initial batch
const submit = await fetch("https://api.spidra.io/api/batch/scrape", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ urls, ...options }),
});
const { batchId } = await submit.json();
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
// Poll until terminal
let data;
while (true) {
const res = await fetch(
`https://api.spidra.io/api/batch/scrape/${batchId}`,
{ headers: { Authorization: "Bearer YOUR_API_KEY" } }
);
data = await res.json();
if (["completed", "failed", "cancelled"].includes(data.status)) break;
await new Promise((r) => setTimeout(r, 3000));
}
if (data.failedCount === 0) break; // All done
if (attempt < maxAttempts) {
console.log(`Attempt ${attempt}: ${data.failedCount} failed. Retrying...`);
await fetch(
`https://api.spidra.io/api/batch/scrape/${batchId}/retry`,
{ method: "POST", headers: { Authorization: "Bearer YOUR_API_KEY" } }
);
}
}
// Fetch final state
const final = await fetch(
`https://api.spidra.io/api/batch/scrape/${batchId}`,
{ headers: { Authorization: "Bearer YOUR_API_KEY" } }
);
return (await final.json()).items;
}
Response
202 Accepted:
{
"status": "queued",
"retriedCount": 3
}
| Field | Type | Description |
|---|---|---|
status | "queued" | Confirms the retry was accepted |
retriedCount | number | Number of failed items that were re-queued |
- Failed items reset to
pendingstatus - Batch
failedCountdecrements byretriedCount - Batch
statusresets torunning - Poll the same
batchId— it will complete again when all retried items finish
Errors
| Code | Reason |
|---|---|
400 | No failed items to retry in this batch |
401 | Missing API key authentication header |
403 | Monthly credit limit reached — not enough credits to reserve for the retry |
404 | No batch found with this ID, or it belongs to a different user |
{
"status": "error",
"message": "No failed items to retry.",
"code": "NO_FAILED_ITEMS"
}
Get Batch Status
Poll for results after retrying
Cancel a Batch
Stop the batch entirely instead
Authorizations
BearerAuthApiKeyAuth
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The batch ID containing failed items to retry
Was this page helpful?
⌘I

