Jobs Endpoint

Create and manage asynchronous scraping jobs for bulk operations and long-running scrapes.

POST/v1/jobs

Create a Job

Create a new scraping job that runs asynchronously. Ideal for scraping multiple URLs or complex extractions.

Request
curl -X POST https://api.scrpy.co/v1/jobs \
  -H #a5d6ff;">"Authorization: Bearer sk_live_xxxxx" \
  -H #a5d6ff;">"Content-Type: application/json" \
  -d #a5d6ff;">'{
    "name": "Product Scrape",
    "urls": [
      "https://store.com/product/1",
      "https://store.com/product/2",
      "https://store.com/product/3"
    ],
    "selectors": {
      "title": "h1",
      "price": ".price"
    },
    "webhook": "https://yoursite.com/webhook"
  }'
Response
{
  "success": true,
  "job": {
    "id": "job_abc123",
    "name": "Product Scrape",
    "status": "pending",
    "totalUrls": 3,
    "completedUrls": 0,
    "createdAt": "2024-01-15T10:30:00Z"
  }
}
GET/v1/jobs/:id

Get Job Status

Retrieve the current status and results of a scraping job.

javascript
{
  "success": true,
  "job": {
    "id": "job_abc123",
    "name": "Product Scrape",
    "status": "completed",
    "totalUrls": 3,
    "completedUrls": 3,
    "failedUrls": 0,
    "results": [
      {
        "url": "https://store.com/product/1",
        "data": { "title": "Product 1", "price": "$29.99" }
      },
      {
        "url": "https://store.com/product/2",
        "data": { "title": "Product 2", "price": "$39.99" }
      },
      {
        "url": "https://store.com/product/3",
        "data": { "title": "Product 3", "price": "$49.99" }
      }
    ],
    "createdAt": "2024-01-15T10:30:00Z",
    "completedAt": "2024-01-15T10:31:15Z"
  }
}
GET/v1/jobs

List Jobs

List all jobs with optional filtering and pagination.

Query Parameters

ParameterTypeDescription
statusstringFilter by status: pending, running, completed, failed
limitnumberMax results (default: 20, max: 100)
offsetnumberSkip results for pagination
DELETE/v1/jobs/:id

Cancel Job

Cancel a pending or running job. Completed URLs will still be charged.

Job Statuses

pendingJob created, waiting to start
runningJob is actively scraping URLs
completedAll URLs processed successfully
partialCompleted with some failures
failedJob failed to complete

Related