Web-API

Web API
Welcome to the official repository overview for Oxylabs' Web API, a reliable, fresh web data collection API for applications and AI agents. This guide is a developer-focused, technical reference covering what Web API is, how it works, its key features, agent integrations, and when it fits your web scraping, web searching, or RAG pipeline workflows. It also serves as the central hub linking to all Web API-related repositories, code examples, and integrations.
What is Web API?
Oxylabs Web API is a REST API that lets your code or your AI agent search the web and read web pages in real time. You send an HTTP request; it handles JavaScript rendering, server-side traffic challenges, proxy rotation, and geo-targeting, and returns the result in the format you ask for.
It exposes two endpoints, one for each stage of web data acquisition:
| Endpoint |
Used for |
Input |
/search |
Discovering and ranking organic web results (the Web Search API) |
Keyword / query |
/scrape |
Rendering and extracting page data as Markdown, HTML, JSON, or screenshot (web scraping and data extraction) |
Page URL |
The endpoints are designed to be used together: search to find, scrape to read. Search results contain short snippets, so anything that needs to be accurate should come from a /scrape call.
How it works
- Send a query to
/v1/search and get a ranked list of results with titles, URLs, and snippets.
- Pick the pages worth reading and send their URLs to
/v1/scrape, requesting markdown output.
- Use the returned content in your application, your AI agent, or an LLM pipeline.
All requests go to https://webapi.oxylabs.io and are authenticated with an API key sent as a Bearer token.
Quick start
You can be making requests in three steps – get an API key, search your query, then scrape.
1. Get an API key
In the Oxylabs dashboard, create a Web API instance, copy the API key from that instance, and export it in your terminal or project environment:
export OXYLABS_WEB_API_KEY=your_api_key_here
See the Authentication steps for key handling and rotation.
2. Search the web
curl https://webapi.oxylabs.io/v1/search \
-H "Authorization: Bearer $OXYLABS_WEB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"query": "eu ai act compliance deadlines", "max_results": 3}'
The response contains a ranked results array. Each result has a title, a url, an outline (snippet), and its metadata.position:
{
"state": "done",
"results": [
{
"title": "Implementation Timeline | EU Artificial Intelligence Act",
"outline": ["Date 2 August 2025 Providers: need to be compliant with the AI Act by 2 August 2027..."],
"url": "https://artificialintelligenceact.eu/implementation-timeline/",
"metadata": { "position": 1 }
}
],
"params": { "query": "eu ai act compliance deadlines", "location": null, "max_results": 3 },
"metadata": { "timestamp": 1787431568, "request_id": "1788875675880097469" }
}
3. Scrape a page
Read a page returned by /search, or any URL from your own list:
curl https://webapi.oxylabs.io/v1/scrape \
-H "Authorization: Bearer $OXYLABS_WEB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"url": "https://artificialintelligenceact.eu/implementation-timeline/",
"output": ["markdown"]
}'
The page content is returned in results[0].markdown.
Python: search-to-scrape in one workflow
Search snippets are truncated, so they are not enough for deep analysis or LLM pipelines. The standard pattern is to query /v1/search to discover links, then send those URLs to /v1/scrape with Markdown output:
import os, requests
API = "https://webapi.oxylabs.io"
HEADERS = {"Authorization": f"Bearer {os.environ['OXYLABS_WEB_API_KEY']}"}
def research(question: str, read_top: int = 2) -> list[dict]:
# 1. Discover target URLs
hits = requests.post(
f"{API}/v1/search",
headers=HEADERS,
json={"query": question, "max_results": 10},
timeout=120,
)
hits.raise_for_status()
# 2. Extract full page content as Markdown
pages = []
for hit in hits.json()["results"][:read_top]:
page = requests.post(
f"{API}/v1/scrape",
headers=HEADERS,
json={"url": hit["url"], "output": ["markdown"]},
timeout=120,
)
if not page.ok:
print(f"skipped {hit['url']}: {page.status_code}")
continue
pages.append(
{
"url": hit["url"],
"title": hit["title"],
"content": page.json()["results"][0]["markdown"],
}
)
return pages
for page in research("eu ai act compliance deadlines"):
print(f"--- {page['title']} ({page['url']})")
print(page["content"][:500])
Node.js and Python snippets for each endpoint are in the official documentation. Using an AI agent instead? Jump to Agent-native web access.
Ready to try it? Claim the welcome credits and start for free.
Features
Web API combines web searching, web scraping, and data extraction behind one REST interface. Access handling (JavaScript rendering, traffic challenges, proxy rotation, and geo-targeting) is done by the service, so your code only sends a query or a URL.
Web Search API: /v1/search
Returns ranked organic web results for a keyword or query. Each result includes a title, a URL, a short snippet (outline), and its position. Set max_results to control how many results you get; the response echoes the query, location, and max_results it used. Search is synchronous only.
Snippets are truncated, so use /search to discover pages and /scrape to read them. Full parameters are in the /search documentation.
Web scraping: /v1/scrape
Fetches a page by URL and handles headless rendering, proxy rotation, access challenges, and localization. Request parameters:
| Parameter |
What it does |
Notes |
url |
Absolute http / https page to fetch |
Required |
output |
Response format: markdown, html, json, screenshot; several can be combined |
Default: html |
json |
Custom AI parsing with a prompt or a schema |
Used with output: ["json"] |
location |
Two-letter country code (e.g. US, DE, JP) for geo-targeted results |
Optional |
device |
desktop or mobile user-agent and viewport emulation |
Default: desktop |
run_js |
Execute the page's JavaScript before capture |
Default: false |
Output formats
markdown: the page converted to clean, structured Markdown, optimized for LLM context windows to minimize token usage.
html: raw page markup, for when you need attributes, embedded JSON-LD, or inline data.
json: structured data extracted in the same request as the fetch, with no selectors to write or maintain.
screenshot: a base64-encoded PNG of the rendered page. Requires run_js: true.
JavaScript rendering (run_js). Set run_js: true for client-side scripts, dynamic requests, and single-page applications. Rendering increases request time, so use a client timeout of at least 150 seconds and skip it for static pages and feeds.
Geo-targeting (location). Requests are routed through localized proxy exit nodes so that regional pricing, language variations, and region-exclusive content are served correctly.
Full parameters and the output dictionary are in the /scrape documentation.
AI-powered data extraction (AI Parsing)
Request output: ["json"] and add a json object to extract custom fields from any page in the same call. Choose one of two modes per request:
| Mode |
You provide |
Best for |
prompt |
A natural-language description of the fields to extract |
Prototyping, exploring a page, simple key-value extraction |
schema |
An OpenAPI / JSON Schema object the result must match |
Production pipelines and typed applications |
{
"url": "https://example.com/product/10928",
"output": ["json"],
"json": {
"prompt": "Extract the main product title, current sale price as a number, currency code, and a list of image URLs."
}
}
Note: AI parsing uses significantly more account credit than a regular /scrape request. See AI Parsing for schema patterns and localized extraction.
Dedicated scrapers
Beyond generic URL scraping, target-specific scrapers are available at POST /v1/scrape/{target}/{collection}. They take target-specific parameters (for example ASINs or store zip codes) and return structured fields under results[].json. Target overviews cover Google, Amazon, YouTube, Bing, AI & LLMs, and Commerce. Head over to Dedicated Scrapers documentation to learn about specific targets.
curl https://webapi.oxylabs.io/v1/scrape/amazon/product \
-H "Authorization: Bearer $OXYLABS_WEB_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"query": "B0935DN1BN",
"output": ["json"],
"location": "10115",
"domain": "de",
"currency": "EUR"
}'
Delivery modes
Three ways to receive /scrape results, depending on volume and latency needs:
| Delivery |
Endpoint |
Max items per request |
Used for |
| Realtime (synchronous) |
POST /v1/scrape/{source} |
1 |
Low-latency requests, testing |
| Async single (polling) |
POST /v1/async/scrape/{source} |
1 |
High concurrency and volume |
| Async batch (bulk queue) |
POST /v1/async/scrape/batch/{source} |
5,000 |
Bulk ingestion |
Async results can be retrieved by polling, by webhook (callback_url), or by delivery to cloud storage (s3, s3_gzip, s3_compatible, gcs, or tos). Batch routing is available for select sources only, and some endpoints (for example YouTube downloads, ChatGPT, Gemini, and Perplexity) do not support real-time delivery. Visit the Delivery Modes page for more information.
Authentication, errors, and request IDs
Every request uses a Bearer API key from a Web API instance (check the Authentication page). Each response carries a metadata.request_id; include it in support tickets. For HTTP status codes and retry guidance, refer to Troubleshooting.
Agent-native web access: AI agent integrations
Web API is built to be plugged into AI agents, coding assistants (such as Claude Code and Cursor), and custom agent frameworks. There are three ways to connect it, and they can be combined.
|
Integration prompt |
Agent skills |
MCP server |
| What it is |
A prompt you paste into an AI coding agent so it builds the integration for your project |
Instructions that teach an agent how to use Web API |
A server that exposes Web API as callable tools |
| Gives the agent |
A spec to follow (base URL, auth, schemas, retry rules, checklist) |
Judgment: when to search, which sources to trust, how to cite |
Typed tools it can call directly |