Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Extractions

The extractions API lets you extract design tokens from any URL.

Endpoints

Create Extraction

Start a new CSS extraction job.

POST /api/extractions

Request Body:

{
  "url": "https://example.com",
  "options": {
    "wait_for": "networkidle",
    "viewport": { "width": 1920, "height": 1080 },
    "selectors": ["#header", ".main-content"],
    "exclude_selectors": [".ad-banner"]
  }
}
FieldTypeRequiredDescription
urlstringYesURL to extract from
options.wait_forstringNoWait condition: load, domcontentloaded, networkidle
options.viewportobjectNoBrowser viewport size
options.selectorsarrayNoLimit extraction to specific elements
options.exclude_selectorsarrayNoExclude elements from extraction

Response:

{
  "id": "ext_abc123",
  "url": "https://example.com",
  "status": "pending",
  "created_at": "2024-01-15T10:30:00Z"
}

The extraction runs asynchronously. Poll the status endpoint or use webhooks to know when it’s complete.


List Extractions

Get all extractions for your account.

GET /api/extractions

Query Parameters:

ParameterTypeDefaultDescription
pageinteger1Page number
per_pageinteger20Results per page (max 100)
statusstringβ€”Filter by status

Response:

{
  "data": [
    {
      "id": "ext_abc123",
      "url": "https://example.com",
      "status": "completed",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "per_page": 20,
    "total": 42
  }
}

Get Extraction

Retrieve a specific extraction with its tokens.

GET /api/extractions/:id

Response:

{
  "id": "ext_abc123",
  "url": "https://example.com",
  "status": "completed",
  "tokens": {
    "colors": [
      {
        "name": "primary",
        "value": "#3b82f6",
        "format": "hex",
        "usage": 42
      },
      {
        "name": "background",
        "value": "#ffffff",
        "format": "hex",
        "usage": 156
      }
    ],
    "typography": [
      {
        "family": "Inter",
        "weights": ["400", "600", "700"],
        "sizes": ["14px", "16px", "24px", "32px"]
      }
    ],
    "spacing": [
      "4px", "8px", "12px", "16px", "24px", "32px", "48px", "64px"
    ],
    "assets": [
      {
        "type": "image",
        "url": "https://example.com/logo.svg",
        "dimensions": { "width": 120, "height": 40 }
      }
    ]
  },
  "metadata": {
    "title": "Example Domain",
    "duration_ms": 2340,
    "elements_analyzed": 847
  },
  "created_at": "2024-01-15T10:30:00Z",
  "completed_at": "2024-01-15T10:30:02Z"
}

Extraction Status

StatusDescription
pendingExtraction queued, waiting to start
runningBrowser is loading the page
completedExtraction finished successfully
failedExtraction encountered an error

Token Types

Colors

{
  "name": "primary",
  "value": "#3b82f6",
  "format": "hex",
  "usage": 42,
  "contexts": ["background-color", "border-color"]
}

Typography

{
  "family": "Inter",
  "weights": ["400", "600", "700"],
  "sizes": ["14px", "16px", "24px"],
  "line_heights": ["1.4", "1.5", "1.6"]
}

Spacing

An array of unique spacing values found in margins, paddings, and gaps:

["4px", "8px", "12px", "16px", "24px", "32px"]

Assets

{
  "type": "image",
  "url": "https://example.com/logo.svg",
  "dimensions": { "width": 120, "height": 40 },
  "format": "svg"
}

Error Responses

StatusCodeDescription
400invalid_urlThe provided URL is malformed
404not_foundExtraction not found
422extraction_failedBrowser failed to load the page
429rate_limitedToo many requests
{
  "error": {
    "code": "extraction_failed",
    "message": "Failed to load page: timeout after 30s"
  }
}