get_batch_results
Recupere resultados paginados de un trabajo de batch_scrape. Envíe el lote una vez y después consulte este endpoint con el batchId devuelto para comprobar el estado y recorrer los resultados a medida que se completan.
Casos de uso
Consultar un lote en curso
Compruebe el estado del trabajo y recupere las páginas ya terminadas mientras el resto del lote sigue ejecutándose.
Recorrer trabajos grandes
Recorra los resultados de 25 en 25 (hasta 100 por página) en lugar de mantener un lote entero en memoria.
Reanudar tras un reinicio
El batchId sobrevive a su proceso: un worker que se cae puede continuar exactamente donde lo dejó.
Comprobaciones de estado económicas
Con 1 credit por llamada, consultar el estado cuesta una fracción de volver a ejecutar el lote que ya pagó.
Endpoint
/api/v1/tools/get_batch_resultsParameters
batchId procede de la respuesta de batch_scrape: esta herramienta nunca inicia un trabajo, solo lo lee.| Name | Type | Required | Default | Description |
|---|---|---|---|---|
batchId | string | Required | - | El identificador del trabajo por lotes devuelto por `batch_scrape`. Example: batch_1700000000000_abc123def |
page | number | Optional | 1 | Número de página que se va a recuperar (empieza en 1). Example: 1 |
limit | number | Optional | 25 | Resultados por página (1-100). Example: 50 |
Ejemplos de solicitud
cURL
curl -X POST https://crawlforge.dev/api/v1/tools/get_batch_results \
-H "X-API-Key: cf_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"batchId": "batch_1700000000000_abc123def",
"page": 1,
"limit": 25
}'TypeScript
async function getPage(batchId: string, page: number) {
const response = await fetch('https://crawlforge.dev/api/v1/tools/get_batch_results', {
method: 'POST',
headers: {
'X-API-Key': process.env.CRAWLFORGE_API_KEY!,
'Content-Type': 'application/json',
},
body: JSON.stringify({ batchId, page, limit: 25 }),
});
return response.json();
}
// Read total_pages from the first response, then loop — one fewer call than
// incrementing until you get an empty array.
const first = await getPage('batch_1700000000000_abc123def', 1);
if (first.success) {
const all = [...first.data.results];
for (let page = 2; page <= first.data.total_pages; page++) {
const next = await getPage(first.data.batch_id, page);
all.push(...next.data.results);
}
console.log(`Batch ${first.data.status}: ${all.length} of ${first.data.total} results`);
console.log('Credits remaining:', first.credits_remaining);
} else {
console.error('Error:', first.error);
}Python
import requests
import os
def get_page(batch_id, page):
response = requests.post(
'https://crawlforge.dev/api/v1/tools/get_batch_results',
headers={
'X-API-Key': os.environ['CRAWLFORGE_API_KEY'],
'Content-Type': 'application/json',
},
json={'batchId': batch_id, 'page': page, 'limit': 25}
)
return response.json()
# Read total_pages from the first response, then loop — one fewer call than
# incrementing until you get an empty list.
first = get_page('batch_1700000000000_abc123def', 1)
if first['success']:
all_results = list(first['data']['results'])
for page in range(2, first['data']['total_pages'] + 1):
nxt = get_page(first['data']['batch_id'], page)
all_results.extend(nxt['data']['results'])
print(f"Batch {first['data']['status']}: {len(all_results)} of {first['data']['total']} results")
print(f"Credits remaining: {first['credits_remaining']}")
else:
print(f"Error: {first['error']}")Ejemplo de respuesta
{ "success": true, "data": { "batch_id": "batch_1700000000000_abc123def", "status": "completed", "page": 1, "limit": 25, "total": 3, "total_pages": 1, "results": [ { "url": "https://example.com/page-1", "status": "completed", "data": { "title": "Example page 1" } }, { "url": "https://example.com/page-2", "status": "completed", "data": { "title": "Example page 2" } } ] }, "credits_used": 1, "credits_remaining": 999, "processing_time": 96}data.batch_idEl trabajo por lotes que consultó, devuelto tal cualdata.statusEstado del lote en su conjuntodata.totalNúmero total de resultados en todas las páginasdata.total_pagesCuántas páginas existen con el `limit` actualdata.resultsUna entrada por cada URL de esta página, cada una con su propio `status` individualcredits_usedCredits descontados por esta solicitud (1 por recuperación)credits_remainingSu saldo de credits restanteManejo de errores
Entrada no válida (400 Bad Request)
batchId está vacío, page es menor que 1, o limit queda fuera del rango 1-100.
Fallo en la recuperación (500 Internal Server Error)
No se pudo leer el lote, normalmente por un batchId desconocido o caducado. No se descuentan credits por una recuperación fallida.
Credits insuficientes (402 Payment Required)
Su cuenta no tiene suficientes credits. Compre más credits o mejore su plan.
Límite de velocidad superado (429 Too Many Requests)
Ha superado el límite de velocidad de su plan. Espere un momento o mejore su plan para obtener límites más altos.
total_pages de la primera respuesta y recorra hasta obtenerlas todas, en lugar de incrementar page hasta recibir un array vacío: ahorra una llamada por lote.Coste en credits
batch_scrape.Plan Free: 1,000 credits por única vez = 1.000 solicitudes
Plan Hobby: 5.000 credits/mes = 5.000 solicitudes (19 USD/mes)
Plan Professional: 50.000 credits/mes = 50.000 solicitudes (99 USD/mes)
Plan Business: 250.000 credits/mes = 250.000 solicitudes (399 USD/mes)