AgentQL REST API reference
AgentQL's REST API allows you to query web pages and documents like PDFs and image files to retrieve the results through HTTP requests from any language.
Query data
Queries structured data as JSON from a web page given a URL using either an AgentQL query.
curl -X POST https://api.agentql.com/v1/query-data \
-H "X-API-Key: $AGENTQL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "{ products[] { product_name product_price(integer) } }",
"url": "https://scrapeme.live/?s=fish&post_type=product",
"params": {
"wait_for": 0,
"is_scroll_to_bottom_enabled": false,
"mode": "fast",
"is_screenshot_enabled": false
}
}'Make sure to replace $AGENTQL_API_KEY with your actual API key.
{
"data": {
"products": [
{
"product_name": "Qwilfish",
"price": 77
},
{
"product_name": "Huntail",
"price": 52
},
...
]
},
"metadata": {
"request_id": "ecab9d2c-0212-4b70-a5bc-0c821fb30ae3"
}
}Authentication
All requests to the AgentQL API must include an X-API-Key header with your API key.
You can generate an API key through Dev Portal.
Request body for web queries
-
querystring (alternative toprompt)The AgentQL query to execute. Learn more about how to write an AgentQL query in the docs. Note: You must define either a
queryor apromptto use AgentQL. -
promptstring (alternative toquery)A Natural Language description of the data to query the page for. AgentQL infers the data structure from your prompt. Note: You must define either a
queryor apromptto use AgentQL. -
urlstring (alternative tohtml)The URL of the public web page you want to query. Note: You must define either a
urlorhtmlto use AgentQL. -
htmlstring (alternative tourl)The raw HTML to query data from. Useful if you have a private or locally generated copy of a web page. Note: You must define either a
urlorhtmlto use AgentQL. -
paramsobject (optional)-
wait_fornumberThe number of seconds to wait for the page to load before querying. Defaults to
0. -
is_scroll_to_bottom_enabledbooleanWhether to scroll to bottom of the page before querying. Defaults to
false. -
modestrstandarduses deep data analysis, whilefasttrades some depth of analysis for speed and is adequate for most usecases. Learn more about the modes in this guide. Defaults tofast. -
is_screenshot_enabledbooleanWhether to take a screenshot before extracting data. Returned in
metadataas a Base64 string. Defaults tofalse.
-
Response for web queries
-
dataobjectData that matches the query.
-
metadataobject-
request_idstringA Universally Unique Identifier (UUID) for the request.
-
screenshotstring | nullBase64 encoded screenshot if enabled,
nullotherwise. You can convert the Base64 string returned in thescreenshotfield to an image and view it using free online tools like Base64.guru.
-
Create remote browser session
Create a remote browser session that provides a Chrome DevTools Protocol (CDP) URL for connecting to a remote browser instance. This allows you to run browser automation on remote infrastructure.
curl -X POST https://api.agentql.com/v1/tetra/sessions \
-H "X-API-Key: $AGENTQL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"browser_ua_preset": "windows"
}'Make sure to replace $AGENTQL_API_KEY with your actual API key.
{
"session_id": "ca7947a1-a188-4391-be82-fb968ce4df4a",
"cdp_url": "wss://ca7947a1-a188-4391-be82-fb968ce4df4a.tetra.agentql.com",
"base_url": "https://ca7947a1-a188-4391-be82-fb968ce4df4a.tetra.agentql.com"
}Authentication
All requests to the AgentQL API must include an X-API-Key header with your API key.
You can generate an API key through Dev Portal.
Request body for browser sessions
-
browser_ua_presetstring (optional)User agent preset to simulate different operating systems. Supported values:
windows,macos,linux.
Response for browser sessions
-
cdp_urlstringChrome DevTools Protocol URL for connecting to the remote browser using Playwright or similar automation tools. That's what you need to connect to the remote browser using
connect_over_cdpmethod. -
base_urlstringBase URL for accessing browser session resources and streaming endpoints.
-
session_idstringUnique identifier for the browser session.
Use the remote browser session
Once you have created a browser session, you can connect to it using Playwright:
from playwright.async_api import async_playwright
async def use_remote_browser():
# Get session from previous API call
cdp_url = session_data['cdp_url']
async with async_playwright() as p:
browser = await p.chromium.connect_over_cdp(cdp_url)
# Use browser normally
page = await browser.new_page()
await page.goto('https://example.com')
# View the page in real-time (optional)
streaming_url = f"{session_data['base_url']}/stream/0"
print(f"View at: {streaming_url}")For easier integration, use the AgentQL SDK which provide convenient wrapper functions:
- Python:
from agentql.tools.sync_api import create_browser_session - JavaScript:
import { createBrowserSession } from 'agentql/tools'
See the Remote Browser Guide for complete examples.
Query document
Extract data from a document by sending a PDF or image (JPEG, JPG, PNG) file and an AgentQL query. Learn about the consumption logic for querying documents here
for this example, use the following example file

The query_document function consumes 1 API call per image (JPG, JPEG, JPG), and 1 API call for each page within a PDF. (i.e querying a 10-page PDF will take 10 AgentQL API calls)
curl -X POST https://api.agentql.com/v1/query-document \
-H "X-API-Key: $AGENTQL_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "file=@/path/to/file.pdf" \
-F 'body="{\"query\": \"{ project { id lowest_bidder lowest_bid } } \", \"params\": { \"mode\": \"fast\" } }" 'Make sure to replace $AGENTQL_API_KEY with your actual API key.
{
"data": {
"project": {
"id": "CPM 81031-200202",
"lowest_bidder": "Toebe Construction LLC",
"lowest_bid": 13309641.63
}
},
"metadata": {
"request_id": "ecab9d2c-0212-4b70-a5bc-0c821fb30ae3"
}
}Authentication
All requests to the AgentQL API must include an X-API-Key header with your API key.
You can generate an API key through Dev Portal.
Request body for document queries
The request body for querying documents is a multipart/form-data object that contains a file and a body.
-
filestringFile Path of file to execute query on.
-
bodystringThe body is a stringified JSON that represents parameters for the query because
multipart/form-dataonly takes string.querystring (alternative toprompt):
The AgentQL query to execute. Learn more about how to write an AgentQL query in the docs. Note: You must define either a
queryor apromptto use AgentQL.promptstring (alternative toquery):
A Natural Language description of the data to query the page for. AgentQL infers the data structure from your prompt. Note: You must define either a
queryor apromptto use AgentQL.paramsobject (optional):
representation of the parameters for the query.
modestr: Specifies the extraction mode:standardfor complex or high-volume data, orfastfor typical use cases. Defaults tofast.
Response for document queries
-
dataobjectData that matches the query
-
metadataobject-
request_idstringA UUID for the request
-
The query_document is supported in Python SDK. Learn how to use it here