POST
/
v1
/
searchscraper

Request Body

user_prompt
string
required

The search query or question you want to ask. This should be a clear and specific prompt that will guide the AI in finding and extracting relevant information.

Example: “What is the latest version of Python and what are its main features?”

headers
object

Optional headers to customize the search behavior. This can include user agent, cookies, or other HTTP headers.

Example:

{
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
  "Cookie": "cookie1=value1; cookie2=value2"
}
output_schema
object

Optional schema to structure the output. If provided, the AI will attempt to format the results according to this schema.

Example:

{
  "properties": {
    "version": {"type": "string"},
    "release_date": {"type": "string"},
    "major_features": {"type": "array", "items": {"type": "string"}}
  },
  "required": ["version", "release_date", "major_features"]
}

Response

request_id
string

Unique identifier for the search request. Use this ID to check the status and retrieve results.

status
string

Status of the request. One of: “queued”, “processing”, “completed”, “failed”

user_prompt
string

The original search query that was submitted.

result
object

The search results. If an output_schema was provided, this will be structured according to that schema.

reference_urls
array

List of URLs that were used as references for the answer.

error
string

Error message if the request failed. Empty string if successful.

Example Request

curl -X POST 'https://api.scrapegraphai.com/v1/searchscraper' \
-H 'SGAI-APIKEY: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
  "user_prompt": "What is the latest version of Python and what are its main features?",
  "output_schema": {
    "properties": {
      "version": {"type": "string"},
      "release_date": {"type": "string"},
      "major_features": {"type": "array", "items": {"type": "string"}}
    },
    "required": ["version", "release_date", "major_features"]
  }
}'

Example Response

{
  "request_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "completed",
  "user_prompt": "What is the latest version of Python and what are its main features?",
  "result": {
    "version": "3.12",
    "release_date": "October 2, 2023",
    "major_features": [
      "Improved error messages",
      "Per-interpreter GIL",
      "Support for the Linux perf profiler",
      "Faster startup time"
    ]
  },
  "reference_urls": [
    "https://www.python.org/downloads/",
    "https://docs.python.org/3.12/whatsnew/3.12.html"
  ],
  "error": ""
}