Skip to main content

Jobs API

Track the status of background jobs for crawl and discovery operations.

When you trigger a crawl or discovery, Diffy queues the work as a background job. Use these endpoints to monitor job progress and view results.

List Jobs

GET /api/jobs

Query Parameters

ParameterTypeDescription
limitintegerMax results (default: 20, max: 100)
statusstringFilter by status: waiting, active, completed, failed

Response

{
"data": [
{
"id": "12345",
"name": "crawl.page",
"type": "crawl",
"url": "https://competitor.com/pricing",
"domainId": "550e8400-e29b-41d4-a716-446655440000",
"pageId": "550e8400-e29b-41d4-a716-446655440001",
"state": "completed",
"progress": 100,
"attemptsMade": 1,
"createdAt": "2024-01-15T10:30:00Z",
"processedAt": "2024-01-15T10:30:05Z",
"finishedAt": "2024-01-15T10:30:12Z",
"failedReason": null
}
],
"meta": {
"total": 1,
"page": 1,
"pageSize": 20
}
}

Get Job

GET /api/jobs/:id

Response

{
"data": {
"id": "12345",
"name": "discover.pages",
"type": "discover",
"url": null,
"domainId": "550e8400-e29b-41d4-a716-446655440000",
"pageId": null,
"state": "completed",
"progress": 100,
"attemptsMade": 1,
"maxAttempts": 3,
"createdAt": "2024-01-15T10:30:00Z",
"processedAt": "2024-01-15T10:30:05Z",
"finishedAt": "2024-01-15T10:30:45Z",
"failedReason": null,
"returnValue": {
"pagesDiscovered": 8,
"pagesAdded": 8
}
}
}

Queue Statistics

GET /api/jobs/stats

Get aggregate statistics for the job queue.

Response

{
"data": {
"waiting": 5,
"active": 2,
"completed": 150,
"failed": 3,
"delayed": 0,
"total": 7
}
}

Job States

StateDescription
waitingJob is queued and waiting to be processed
activeJob is currently being processed
completedJob finished successfully
failedJob failed after all retry attempts
delayedJob is scheduled for future execution

Job Types

TypeDescription
crawl.pageCrawl a single page for changes
discover.pagesDiscover pages on a domain

Error Codes

CodeDescription
NOT_FOUNDJob not found or not owned
UNAUTHORIZEDInvalid or missing API key