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
-
query
stringThe AgentQL query to execute. Learn more about how to write an AgentQL query in the docs.
-
url
string (optional)The URL of the public web page you want to query. Note: You must define either a
url
orhtml
to use AgentQL. -
html
string (optional)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
url
orhtml
to use AgentQL. -
params
object (optional)-
wait_for
numberThe number of seconds to wait for the page to load before querying. Defaults to
0
. -
is_scroll_to_bottom_enabled
booleanWhether to scroll to bottom of the page before querying. Defaults to
false
. -
mode
strstandard
uses deep data analysis, whilefast
trades some depth of analysis for speed and is adequate for most usecases. Learn more about the modes in this guide. Defaults tofast
. -
is_screenshot_enabled
booleanWhether to take a screenshot before extracting data. Returned in
metadata
as a Base64 string. Defaults tofalse
.
-
Response for web queries
-
data
objectData that matches the query.
-
metadata
object-
request_id
stringA Universally Unique Identifier (UUID) for the request.
-
screenshot
string | nullBase64 encoded screenshot if enabled,
null
otherwise. You can convert the Base64 string returned in thescreenshot
field to an image and view it using free online tools like Base64.guru.
-
Query document
Extract data from a webpage by sending a PDF or image (jpg, jpeg, png) file and an AgentQL query.
This endpoint's request format will change soon. Please check back for updated documentation.
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 "query= { students[] { name role } } " \
-F "params= { \"mode\": \"fast\" }"
Make sure to replace $AGENTQL_API_KEY
with your actual API key.
{
"data": {
"students": [
{
"name": "Qwilfish",
"role": "chairman"
},
{
"name": "Huntail",
"role": "vice chairman"
},
...
]
},
"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
You must provide either query
or prompt
, but not both. If both are provided, the request will fail.
-
query
stringThe AgentQL query to execute. Alternatively, you can use the
prompt
field to describe the query. -
prompt
stringNatural language description of what you want to extract from the file. It will convert the prompt into an AgentQL query and execute it.
-
file
pathBuffered Object representation of the file to extract data from
-
params
object (optional)-
mode
strSpecifies the extraction mode:
standard
for complex or high-volume data, orfast
for typical use cases. Defaults tofast
. You can read more about the mode options in Guide. Only configurable in curl requests.
-
This endpoint's request format will change soon. Please check back for updated documentation.
Response for document queries
-
data
objectData that matches the query
-
metadata
object-
request_id
stringA UUID for the request
-