```yaml
product: AlterLab
title: Extract API Reference
category: api
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/docs/api/generated/extract
```

# Extract API Reference

Auto-generated API reference for extract endpoints, built from the OpenAPI spec.

## POST /api/v1/extract

Extract structured data from content
Extract structured data from raw HTML, text, or markdown without scraping. Supports multiple extraction pipelines: format conversion (text, json, json_v2, html, markdown, rag), schema-based filtering, LLM extraction via prompt, and profile-based extraction (product, article, job_posting, etc.). **Cost**: 1 credit per extraction request.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `tag` | body | `string` | no |  |
| `content` | body | `string` | yes | Raw content to extract from (HTML, text, markdown, or base64-encoded PDF) |
| `content_type` | body | `"html" \| "text" \| "markdown"` | no | Type of the provided content |
| `extraction_schema` | body | `object` | no |  |
| `extraction_profile` | body | `"auto" \| "product" \| "article" \| "job_posting" \| "faq" \| "recipe" \| "event" \| "ecommerce_homepage" \| "directory_listing"` | no |  |
| `extraction_template` | body | `"auto" \| "product" \| "article" \| "job_posting" \| "faq" \| "recipe" \| "event" \| "ecommerce_homepage" \| "directory_listing"` | no |  |
| `extraction_selectors` | body | `object` | no |  |
| `extraction_template_id` | body | `string` | no |  |
| `extraction_template_version` | body | `integer` | no |  |
| `extraction_prompt` | body | `string` | no |  |
| `extraction_provider` | body | `"openai" \| "anthropic" \| "openrouter" \| "groq"` | no |  |
| `extraction_model` | body | `string` | no |  |
| `formats` | body | `string[]` | no | Output formats for content transformation |
| `source_url` | body | `string` | no |  |
| `evidence` | body | `boolean` | no | Include field provenance/evidence for extracted fields |
| `cache` | body | `"auto" \| "skip" \| "only"` | no | Cache control for LLM extraction results. auto: return cached result if available (default). skip: bypass cache lookup, always call LLM (result is still stored for future callers). only: return cached result or HTTP 404 if not cached — never calls the LLM. |
| `cache_ttl` | body | `integer` | no |  |

## GET /api/v1/extract/estimate

Estimate extraction cost
Returns the estimated cost for a POST /v1/extract call before committing to it. Useful for displaying cost previews in client UIs or CLI tools. Cost is clamped to a minimum of $0.001 (100 µ¢) and a maximum of $0.50 (50,000 µ¢). When a BYOK key is registered, the LLM invocation fee is 300 µ¢ (flat orchestration fee). Without a registered BYOK key the platform rate of 1000 µ¢ applies.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `content_length` | query | `integer` | yes |  |
| `has_extraction_prompt` | query | `boolean` | no |  |

## GET /api/v1/extract/templates

List extraction templates
Returns all built-in extraction templates plus the authenticated user's saved custom templates. Built-in templates are always present and cannot be deleted.

Authentication: `X-API-Key: <your key>`

## POST /api/v1/extract/templates

Save a custom extraction template
Save a custom JSON Schema as a named extraction template. The saved template can then be referenced when running extractions by supplying its ID or by passing the schema directly.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `name` | body | `string` | yes | Display name for the template |
| `schema` | body | `object` | yes | JSON Schema defining the extraction output structure |
| `tags` | body | `string[]` | no | Tags |

## DELETE /api/v1/extract/templates/{template_id}

Delete a user template
Delete a user-saved extraction template by its UUID.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `template_id` | path | `string` | yes |  |

## GET /api/v1/extract/templates/{template_id}

Get a user template by ID
Retrieve a single user-saved extraction template by its UUID.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `template_id` | path | `string` | yes |  |

## PUT /api/v1/extract/templates/{template_id}

Update a user template
Rename, retag or replace the schema of a saved template. A changed schema is stored as a new version; earlier versions stay readable and runnable.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `template_id` | path | `string` | yes |  |
| `name` | body | `string` | no |  |
| `schema` | body | `object` | no |  |
| `tags` | body | `string[]` | no |  |

## GET /api/v1/extract/templates/{template_id}/versions

List template versions
All stored schema versions of a saved template, newest first.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `template_id` | path | `string` | yes |  |

## GET /api/v1/extract/templates/{template_id}/versions/{version}

Get one template version
Read one stored schema version of a saved template.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `template_id` | path | `string` | yes |  |
| `version` | path | `integer` | yes |  |

## GET /api/v1/extract/usage

List extraction usage history
Returns a paginated list of per-call extraction records for the authenticated user. Records are ordered newest-first. Each record includes provider, model, token counts, AlterLab invocation fee, latency, and success status. Use `date_from` and `date_to` (ISO 8601, e.g. `2026-05-01`) to filter by date range.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `page` | query | `integer` | no |  |
| `page_size` | query | `integer` | no |  |
| `date_from` | query | `string` | no |  |
| `date_to` | query | `string` | no |  |

## GET /api/v1/extract/usage/summary

Aggregate extraction usage totals
Returns period-wide aggregate totals (request count and total billed cost) for the authenticated user's extraction usage. Unlike the paginated /usage endpoint, this endpoint always reflects the full selected period regardless of record count. Pass `hours=N` for recent N hours, or `days=N` for recent N days — but not both. Providing both `hours` and `days` simultaneously returns a 422 error. Omit both to get all-time totals.

Authentication: `X-API-Key: <your key>`

| Parameter | In | Type | Required | Description |
|-----------|----|------|----------|-------------|
| `hours` | query | `integer` | no |  |
| `days` | query | `integer` | no |  |
