Search API
Find relevant web pages by keyword before scraping. Search returns URLs, titles, and snippets — optionally scraping each result inline.
Discovery-First Workflow
Deprecated: use /v1/serp
/v1/search and /v1/search/batch are deprecated aliases of /v1/serp with identical billing. Responses carry a Deprecation header. No removal date has been set. See the migration guide.Overview
Search
POST a query to /api/v1/search. Get back URLs, titles, and snippets from DuckDuckGo (default), Google, or Bing. Pass engine: "auto" for the unified result list. The Python and Node SDKs and the hosted MCP alterlab_search tool use it by default and also return each result page as concise markdown (scrape_results=false for the list only).
Scrape (Optional)
Set scrape_results: true to scrape every result page and get full content back.
Extract (Optional)
Pass an extraction_schema to pull structured data from every result in one call.
Schema Versioning
Every response carries a schema_version field (currently "1"). It changes only on a breaking change; additive fields never bump it. Removals follow a minimum 180-day deprecation window announced in the schema changelog.
POST /v1/search
/api/v1/searchExecute a web search. Returns results synchronously (200) or, when scrape_results is true and there are more than 5 results, returns 202 with a search_id for polling.
curl -X POST https://api.alterlab.io/api/v1/search \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "best headless browsers 2026",
"num_results": 10
}'Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | Search terms (1-500 characters). Send exactly one of query or queries. |
| queries | string[] | No | 1-5 queries in one request, billed as one unit at the single-query price of the engine. More than 5 returns 422 too_many_queries before any charge. The response holds results[] with per-query query, status (succeeded, failed, processing), error and response; a failing query never fails the others. Works with scrape_results. |
| domain | string | No | Restrict results to a specific domain (applied as site: prefix) |
| num_results | integer | No | Number of results to return (1-50, default: 10) |
| country | string | No | ISO 3166-1 alpha-2 country code for geo-targeted results (e.g., US, GB, DE) |
| language | string | No | Language code for results (e.g., en, fr, de) |
| time_range | string | No | Filter by recency: hour, day, week, month, year |
| scrape_results | boolean | No | If true, scrape each result page and include full content (default: false) |
| engine | string | No | duckduckgo (default, $0.001/query), google or bing ($0.004/query each), or auto ($0.001/query, unified search). See Pricing below. |
| safe_search | boolean | No | Enable the engine's safe-search filter |
| zero_data_retention | boolean | No | Store nothing about the query or its results beyond the request: no poll pointer, cache entry or query text in usage records, and the job record is deleted once the response is built. Incompatible with scrape_results and batch search (422 zero_data_retention_unsupported). Defaults to the account setting; enable it account-wide, or set a shorter job retention window (1-90 days), in your organization settings. |
| formats | string[] | No | Output formats when scrape_results=true: text, json, json_v2, html, markdown, rag, content |
| extraction_schema | object | No | JSON schema for structured extraction (when scrape_results=true) |
Search-Only Response (200)
When scrape_results is false (default), results are returned synchronously:
{
"search_id": "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"query": "best headless browsers 2026",
"results_count": 10,
"credits_used": 2000,
"results": [
{
"url": "https://example.com/headless-browsers-guide",
"title": "Top 10 Headless Browsers in 2026",
"snippet": "A comprehensive comparison of the best headless browsers for web scraping and automation...",
"position": 1,
"content": null
},
{
"url": "https://blog.example.com/playwright-vs-puppeteer",
"title": "Playwright vs Puppeteer in 2026",
"snippet": "Which headless browser framework should you choose? We compare performance, features...",
"position": 2,
"content": null
}
]
}Search + Scrape Response (202)
When scrape_results=true and there are more than 5 results, the response is 202 with a polling URL:
{
"search_id": "a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"query": "best headless browsers 2026",
"status": "scraping",
"results_count": 10,
"credits_used": 52000,
"results": [ ... ],
"message": "Search complete. 10 results are being scraped. Poll GET /api/v1/search/a1b2c3d4-... for progress."
}Inline Scraping
scrape_results=true and there are 5 or fewer results, the API waits briefly and attempts to return content inline. For larger result sets, use the polling endpoint.GET /api/v1/search/{search_id}
/api/v1/search/{search_id}Poll for search + scrape progress. Returns the search results with scraped content populated as each job completes.
curl https://api.alterlab.io/api/v1/search/a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d \
-H "X-API-Key: your_api_key"Status Response
{
"search_id": "a1b2c3d4-...",
"query": "best headless browsers 2026",
"status": "completed",
"results_count": 10,
"completed": 10,
"credits_used": 52000,
"results": [
{
"url": "https://example.com/headless-browsers-guide",
"title": "Top 10 Headless Browsers in 2026",
"snippet": "A comprehensive comparison...",
"position": 1,
"content": {
"text": "Full article text here...",
"markdown": "# Top 10 Headless Browsers..."
}
}
]
}| Status | Meaning |
|---|---|
| scraping | Some result pages are still being scraped |
| completed | All result pages have been scraped |
24-Hour TTL
Batch Search
Submit up to 50 search queries for async parallel processing. Each query runs independently and results are aggregated. Requires Growth+ balance tier ($50+ balance). Poll for results or receive them via webhook.
Request Body
/api/v1/search/batchSubmit a batch of search queries for asynchronous processing.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| queries | string[] | Required | Search queries to execute (1-50 queries, each max 500 characters) |
| num_results | integer | Optional | Number of results per query (1-30)Default: 10 |
| country | string | Optional | ISO 3166-1 alpha-2 country code applied to all queries (e.g., US, GB, DE) |
| language | string | Optional | Language code applied to all queries (e.g., en, fr, de) |
| time_range | string | Optional | Filter results by recency: hour, day, week, month, year |
| scrape_results | boolean | Optional | If true, scrape each result page for content. Per-page tier costs are debited as scrapes complete.Default: false |
| engine | string | Optional | Search engine for every query: duckduckgo ($0.001/query), google or bing ($0.004/query each), or auto for the unified, vendor-neutral result list (flat $0.001/query).Default: duckduckgo |
| safe_search | boolean | Optional | Enable the engine's safe-search filter. |
| include_ai_overview | boolean | Optional | Google only. Keeps the search on the rendered tier so the response carries ai_overview: {present, text, sections[], references[{title, url, domain, position}]}. No extra charge. The field comes from the engine that served the results and is null when another engine served them or the page had no AI Overview. ai_overview_present stays available.Default: false |
| zero_data_retention | boolean | Optional | Batch search stores queries and results for polling, so it is rejected (422 zero_data_retention_unsupported) when zero data retention is set on the request or the account. |
| formats | string[] | Optional | Output formats when scrape_results=true: text, json, json_v2, html, markdown, rag, content |
| webhook_url | string | Optional | Webhook URL to POST when all queries complete. Receives a batch.search.completed event with batch counts and status; fetch per-query results with GET /api/v1/search/batch/{batch_id}. |
Request Example
curl -X POST https://api.alterlab.io/api/v1/search/batch \
-H "X-API-Key: sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"queries": [
"web scraping best practices",
"structured data extraction",
"API rate limiting strategies"
],
"num_results": 10,
"country": "US",
"webhook_url": "https://your-app.com/webhooks/search"
}'Response Example
{
"batch_id": "b1c2d3e4-f5a6-7890-bcde-f12345678901",
"total_queries": 3,
"status": "processing",
"estimated_credits": 3,
"job_ids": [
"j1-search-001",
"j1-search-002",
"j1-search-003"
],
"message": "Batch search submitted. Poll GET /api/v1/search/batch/{batch_id} for results."
}Response
The POST response returns immediately with a 202 Accepted status. Use the batch_id to poll for results.
Python SDK Example
from alterlab import AlterLabSync
client = AlterLabSync(api_key="YOUR_API_KEY")
# Submit batch search
batch = client.batch_search(
queries=[
"web scraping best practices",
"structured data extraction",
"API rate limiting strategies"
],
num_results=10,
country="US",
engine="google", # duckduckgo (default), google or bing
)
print(f"Batch ID: {batch['batch_id']}")
print(f"Estimated credits: {batch['estimated_credits']}")
# Poll for results
import time
while True:
status = client.get_batch_search(batch["batch_id"])
if status["status"] != "processing":
break
print(f"Progress: {status['completed']}/{status['total']}")
time.sleep(2)
# Process results
for item in status["items"]:
if item["status"] == "succeeded":
print(f"Query: {item['query']}")
for result in item["results"]:
print(f" {result['position']}. {result['title']}")Poll Batch Search Status
Poll the status of a batch search to get per-query results as they complete.
/api/v1/search/batch/{batch_id}Get the current status and results of a batch search.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| batch_id | string | Required | Batch search ID returned from POST /search/batch |
Request Example
curl -X GET https://api.alterlab.io/api/v1/search/batch/b1c2d3e4 \
-H "X-API-Key: sk_live_..."Response Example
{
"batch_id": "b1c2d3e4-f5a6-7890-bcde-f12345678901",
"status": "completed",
"total": 3,
"completed": 3,
"failed": 0,
"pending": 0,
"items": [
{
"job_id": "j1-search-001",
"query": "web scraping best practices",
"status": "succeeded",
"results_requested": 10,
"results_count": 10,
"results": [
{
"url": "https://example.com/scraping-guide",
"title": "Web Scraping Best Practices Guide",
"snippet": "Learn the best practices for building reliable web scrapers...",
"position": 1
}
],
"credits_used": 1
}
],
"total_credits_used": 3,
"created_at": "2025-11-05T10:30:00Z",
"webhook_status": "delivered",
"webhook_attempts": 1
}| Status | Description |
|---|---|
| processing | Queries are still being executed |
| completed | All queries finished successfully |
| partial | All queries finished but some failed |
| failed | All queries failed |
Batch Search Requirements
- Requires Growth+ balance tier ($50+ balance)
- Maximum 50 queries per batch
- Each query is billed up front at the engine rate ($0.001 DuckDuckGo, $0.004 Google or Bing)
- When
scrape_results=true, per-page tier costs are debited as scrapes complete - Batch metadata expires after 24 hours
Unified Search
Set engine to auto to run a single vendor-neutral search on this same route: one request schema, one flat price, deduplicated and ranked results. Responses carry a source_type per result and a cost_breakdown. Cached results are billed at zero. Add scrape_results=true for unified search with content: each result page comes back inline as markdown (preset=agent for the concise form) with a per-result content_status, waiting up to wait seconds or the mode tier. Pages still loading stay pending and resolve under GET /v1/search/{search_id}. Each fetched page is billed at its fetch tier on top of the flat query price.
| Parameter | Description |
|---|---|
| category | One vertical to search (default web). Exclusive with sources. |
| sources | Up to 5 verticals (for example web, news, images) merged into one response. |
| source_limits | Results per source, keyed by source name. |
| freshness | day, week, month or year. |
| date_from / date_to | Publication date window. |
| temporal_bias | RECENT, OLD or NONE. |
| include_domains / exclude_domains | Up to 50 domains each. |
| require_terms / exclude_terms / promote_terms | Up to 20 terms each. |
| max_per_domain | Domain diversity cap, 1-100 (default 2). |
| extra_snippets | Include up to 5 extra snippets per result. |
| timeout_ms | Deadline, 500-10000. |
| zero_data_retention | Store nothing about the query or results. Incompatible with scrape_results, polling and batch. |
curl -X POST https://api.alterlab.io/api/v1/search \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "open source vector databases",
"engine": "auto",
"sources": ["web", "news"],
"freshness": "month",
"num_results": 10,
"scrape_results": true,
"formats": ["markdown"]
}'Multi-Query Requests
Pass queries (1-5 strings) instead of query to run several queries in one request, billed as one unit. The response carries queries_count, succeeded_count, failed_count and one entry per query in request order. More than 5 queries is rejected with the typed error too_many_queries. For long-running multi-step investigations see the Research API.
Pricing
| Action | Cost | Notes |
|---|---|---|
| Search query, engine: duckduckgo | $0.001 (1,000 microcents) | Default engine. Flat fee per query, regardless of num_results |
| Search query, engine: google or bing | $0.004 (4,000 microcents) | Browser-rendered SERP. Flat fee per query |
| Search query, engine: auto (unified) | $0.001 (1,000 microcents) | Flat fee per request. A multi-query request is billed as one unit |
| Scrape per result | Tier cost per URL | Only with scrape_results; standard scrape pricing per URL |
| Extraction | No surcharge | extraction_schema with scrape_results is billed only at the scrape cost |
Responses report credits_used in legacy credit units; balances are charged in USD at the rates above.
BYOP Discount
Error Codes
| Status | Error | Description |
|---|---|---|
| 402 | insufficient_credits | Not enough credits for the search or scrape |
| 404 | search_not_found | Search ID not found or expired (polling endpoint) |
| 502 | search_provider_error | Upstream search provider returned an error |
| 503 | search_unavailable | Search service is not configured |
| 503 | search_timeout | Search did not complete in time (retryable; honor retry_after_s) |
| 503 | engine_blocked | The search engine blocked the request (retryable; honor retry_after_s) |
| 402 | insufficient_balance | Balance could not cover the search when it settled (the up-front check returns insufficient_credits) |
Examples
Basic Search
import requests
response = requests.post(
"https://api.alterlab.io/api/v1/search",
headers={"X-API-Key": "YOUR_API_KEY"},
json={
"query": "web scraping best practices",
"num_results": 5
}
)
data = response.json()
for result in data["results"]:
print(f"{result['position']}. {result['title']}")
print(f" {result['url']}")Domain-Scoped Search
# Search within a specific domain
response = requests.post(
"https://api.alterlab.io/api/v1/search",
headers={"X-API-Key": "YOUR_API_KEY"},
json={
"query": "authentication API",
"domain": "docs.github.com",
"num_results": 10
}
)
# All results will be from docs.github.com
data = response.json()
print(f"Found {data['results_count']} pages on docs.github.com")Search + Scrape with Extraction
import time
# Search and scrape with structured extraction
response = requests.post(
"https://api.alterlab.io/api/v1/search",
headers={"X-API-Key": "YOUR_API_KEY"},
json={
"query": "iPhone 16 Pro review",
"num_results": 5,
"scrape_results": True,
"formats": ["text", "markdown"],
"extraction_schema": {
"type": "object",
"properties": {
"rating": {"type": "number", "description": "Review rating out of 10"},
"pros": {"type": "array", "items": {"type": "string"}},
"cons": {"type": "array", "items": {"type": "string"}},
"verdict": {"type": "string", "description": "One-line summary"}
}
}
}
)
data = response.json()
# If 202, poll for results
if response.status_code == 202:
search_id = data["search_id"]
while True:
status = requests.get(
f"https://api.alterlab.io/api/v1/search/{search_id}",
headers={"X-API-Key": "YOUR_API_KEY"}
).json()
if status["status"] == "completed":
data = status
break
time.sleep(2)
# Process extracted data
for result in data["results"]:
if result.get("content") and result["content"].get("extraction"):
ext = result["content"]["extraction"]
print(f"{result['title']}: {ext.get('rating')}/10")
print(f" Verdict: {ext.get('verdict')}")History, saved queries and keyless search
/api/v1/searchCursor-paged history of your organization's searches, newest first. Pass the returned next_cursor back as cursor. Works with a dashboard session or an API key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | Page size, 1-100.Default: 20 |
| cursor | string | Optional | next_cursor from the previous page. |
| q | string | Optional | Query substring filter. |
| status | string | Optional | completed, scraping or failed. |
| kind | string | Optional | single or multi. |
| since | string | Optional | ISO 8601 lower bound on created_at. |
| until | string | Optional | ISO 8601 upper bound on created_at. |
/api/v1/search/saved-queriesSave a search query with its options so it can be re-run or scheduled. Up to 100 saved queries per user (403 saved_query_limit_reached); names are unique per user (409 saved_query_name_taken).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Display name, up to 120 characters. |
| query | string | Required | Search query, up to 500 characters. |
| options | object | Optional | Stored search options: the /v1/search request fields apart from query and engine (for example num_results, country, device, language, freshness, include_domains). Unknown fields return 422. |
/api/v1/search/saved-queriesList saved search queries.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | Page size, 1-100.Default: 50 |
| offset | integer | Optional | Rows to skip.Default: 0 |
/api/v1/search/saved-queries/{saved_id}Get one saved search query.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| saved_id | string | Required | Saved query ID. |
/api/v1/search/saved-queries/{saved_id}Update a saved query. Omitted fields keep their value.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| saved_id | string | Required | Saved query ID. |
| name | string | Optional | New display name. |
| query | string | Optional | New query text. |
| options | object | Optional | New stored options. |
/api/v1/search/saved-queries/{saved_id}Delete a saved query. Returns 204.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| saved_id | string | Required | Saved query ID. |
/api/v1/search/keylessKeyless search trial: no signup and no API key. Always unified search with 10 results and no content fetch. Limited to 10 requests per minute and 200 per day per IP, halved for hosting-provider networks (429 above that). If the free budget or a backend is unavailable, it returns cached results with a notice instead of an error.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| query | string | Required | Search query, up to 200 characters. |
| category | string | Optional | web, news, code, academic or discussions.Default: web |
| freshness | string | Optional | day, week or month. |
/api/v1/search/demoRun one query in the public search demo. Cached results are served first; a live run happens within per-IP limits. Past the live limit the response is 429 with cached results and turnstile_required: true, and completing the check unlocks more live runs.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| query | string | Required | Search query, up to 200 characters. |
| freshness | string | Optional | Only hour is accepted (events from the last hour). Omit it for no recency filter. |
| turnstile_token | string | Optional | Cloudflare Turnstile token, when the previous response asked for one. |
/api/v1/search/demo/cachedCached demo results only. It never triggers a live run, so it is safe for crawlers.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| query | string | Required | Search query. |
| freshness | string | Optional | Only hour is accepted (events from the last hour). Omit it for no recency filter. |
/api/v1/search/demo/queriesThe demo's one-click query set: events from the last hour, precomputed so it never runs live.
All request parameters (POST /api/v1/search)
| Name | Type | Default | Description |
|---|---|---|---|
| tag | string | Optional spend-attribution tag (^[a-z0-9][a-z0-9_.-]{0,63}$, max 20 active tags per organization). | |
| query | string | Search terms (max 500 characters). | |
| queries | string[] | Multi-query search: 1-5 queries (each max 500 characters) in one request, billed as ONE unit at the price of a single query. | |
| engine | "duckduckgo" | "google" | "bing" | "yahoo" | "auto" | "duckduckgo" | 'auto' runs the unified metasearch: sources are queried in parallel, fused and deduplicated, one flat price, no engine attribution in the response (#38611). |
| domain | string | Restrict results to a specific domain (applied as site: prefix) | |
| depth | "standard" | "deep" | "standard" | Unified search (`engine=auto`) only. |
| num_results | integer | 10 | Number of results to return (1-30). |
| page | integer | 1 | Result page number (1-indexed): page N returns results (N-1)*num_results+1 to N*num_results. |
| country | string | ISO 3166-1 alpha-2 country code for geo-targeted results (e.g., US, GB, DE) | |
| city | string | City to localize results to (e.g. | |
| coordinates | object | Point and radius (lat, lng, radius_km) to localize results to | |
| uule | string | Pre-encoded location (uule) for exact localization. | |
| device | "desktop" | "mobile" | "tablet" | Device to emulate: desktop, mobile or tablet. | |
| language | string | Language code for results (e.g., en, fr, de) | |
| time_range | "hour" | "day" | "week" | "month" | "year" | Filter results by recency | |
| safe_search | boolean | true | Enable safe search filtering (default: true). |
| include_ai_overview | boolean | false | Google only. |
| no_cache | boolean | false | Skip the SERP cache and fetch fresh. |
| zero_trace | boolean | false | Zero data retention for this request: the result is not cached and no raw page or result row is persisted. |
| output | "json" | "html" | "json" | 'html' also returns the fetched SERP page as `raw_html` (exit IPs redacted). |
| fields | string[] | Return only these response fields. | |
| scrape_results | boolean | false | If true, scrape each result page and include content in response |
| formats | "text" | "json" | "json_v2" | "html" | "markdown" | "rag" | "content"[] | Output formats when scrape_results=true | |
| preset | string | Concise agent preset (when scrape_results=true): defaults formats to ['markdown'] and applies sensible character caps. | |
| max_chars_per_result | integer | Per-result character cap across text-like fields (when scrape_results=true) | |
| max_total_chars | integer | Total character cap across all results, applied in rank order | |
| sync | boolean | false | With scrape_results=true, wait up to a bounded budget (about 30s) for the scrapes and return 200 with content in one call. |
| extraction_schema | object | JSON schema for structured extraction (when scrape_results=true) | |
| wait | integer | Synchronous search-with-content (scrape_results=true): seconds to wait for result pages before returning inline (1-60). | |
| mode | "fast" | "standard" | "deep" | Latency tier for search-with-content: fast (wait 5 s), standard (15 s) or deep (60 s). | |
| live | boolean | true | scrape_results=true: true (default) fetches every result page live. |
| category | "web" | "news" | "images" | "code" | "academic" | "discussions" | "pdf" | "gov" | "research" | "developer" | Unified search only: single vertical to search (default web). | |
| sources | "web" | "news" | "images" | "code" | "academic" | "discussions" | "pdf" | "gov" | "research" | "developer"[] | Unified search only: several verticals (e.g. | |
| source_limits | object | Unified search only: results per source, keyed by source name. | |
| freshness | "day" | "week" | "month" | "year" | Unified search only: restrict to recent results. | |
| date_from | string | Unified search only: earliest publication date. | |
| date_to | string | Unified search only: latest publication date. | |
| temporal_bias | "RECENT" | "OLD" | "NONE" | Unified search only: rank newer or older results higher. | |
| include_domains | string[] | ||
| exclude_domains | string[] | ||
| include_keywords | string[] | ||
| exclude_keywords | string[] | ||
| require_terms | string[] | ||
| exclude_terms | string[] | ||
| promote_terms | string[] | ||
| max_per_domain | integer | 2 | Unified search only: domain diversity cap. |
| domain_rules | object[] | ||
| rerank_rules | object[] | ||
| extra_snippets | boolean | false | Unified search only: include up to 5 extra snippets. |
| timeout_ms | integer | Unified search only: deadline (max 10s). | |
| zero_data_retention | boolean | Zero data retention: nothing about this query or its results is stored beyond the request (no poll pointer, cache entry, query text in usage metadata or job record). |