Skip to main content
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 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
}
FieldTypeDescription
status"queued"Confirms the retry was accepted
retriedCountnumberNumber of failed items that were re-queued
After a successful retry:
  • Failed items reset to pending status
  • Batch failedCount decrements by retriedCount
  • Batch status resets to running
  • Poll the same batchId — it will complete again when all retried items finish

Errors

CodeReason
400No failed items to retry in this batch
401Missing API key authentication header
403Monthly credit limit reached — not enough credits to reserve for the retry
404No batch found with this ID, or it belongs to a different user
No failed items:
{
  "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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

batchId
string<uuid>
required

The batch ID containing failed items to retry

Response

Failed items re-queued

status
enum<string>
Available options:
queued
retriedCount
integer

Number of failed items that were re-queued