|
| 1 | +--- |
| 2 | +title: 'Start SearchScraper' |
| 3 | +api: 'POST /v1/searchscraper' |
| 4 | +description: 'Start a new AI-powered web search request' |
| 5 | +--- |
| 6 | + |
| 7 | +## Request Body |
| 8 | + |
| 9 | +<ParamField body="user_prompt" type="string" required> |
| 10 | + 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. |
| 11 | + |
| 12 | + Example: "What is the latest version of Python and what are its main features?" |
| 13 | +</ParamField> |
| 14 | + |
| 15 | +<ParamField body="headers" type="object"> |
| 16 | + Optional headers to customize the search behavior. This can include user agent, cookies, or other HTTP headers. |
| 17 | + |
| 18 | + Example: |
| 19 | + ```json |
| 20 | + { |
| 21 | + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", |
| 22 | + "Cookie": "cookie1=value1; cookie2=value2" |
| 23 | + } |
| 24 | + ``` |
| 25 | +</ParamField> |
| 26 | + |
| 27 | +<ParamField body="output_schema" type="object"> |
| 28 | + Optional schema to structure the output. If provided, the AI will attempt to format the results according to this schema. |
| 29 | + |
| 30 | + Example: |
| 31 | + ```json |
| 32 | + { |
| 33 | + "properties": { |
| 34 | + "version": {"type": "string"}, |
| 35 | + "release_date": {"type": "string"}, |
| 36 | + "major_features": {"type": "array", "items": {"type": "string"}} |
| 37 | + }, |
| 38 | + "required": ["version", "release_date", "major_features"] |
| 39 | + } |
| 40 | + ``` |
| 41 | +</ParamField> |
| 42 | + |
| 43 | +## Response |
| 44 | + |
| 45 | +<ResponseField name="request_id" type="string"> |
| 46 | + Unique identifier for the search request. Use this ID to check the status and retrieve results. |
| 47 | +</ResponseField> |
| 48 | + |
| 49 | +<ResponseField name="status" type="string"> |
| 50 | + Status of the request. One of: "queued", "processing", "completed", "failed" |
| 51 | +</ResponseField> |
| 52 | + |
| 53 | +<ResponseField name="user_prompt" type="string"> |
| 54 | + The original search query that was submitted. |
| 55 | +</ResponseField> |
| 56 | + |
| 57 | +<ResponseField name="result" type="object"> |
| 58 | + The search results. If an output_schema was provided, this will be structured according to that schema. |
| 59 | +</ResponseField> |
| 60 | + |
| 61 | +<ResponseField name="reference_urls" type="array"> |
| 62 | + List of URLs that were used as references for the answer. |
| 63 | +</ResponseField> |
| 64 | + |
| 65 | +<ResponseField name="error" type="string"> |
| 66 | + Error message if the request failed. Empty string if successful. |
| 67 | +</ResponseField> |
| 68 | + |
| 69 | +## Example Request |
| 70 | + |
| 71 | +```bash |
| 72 | +curl -X POST 'https://api.scrapegraphai.com/v1/searchscraper' \ |
| 73 | +-H 'SGAI-APIKEY: YOUR_API_KEY' \ |
| 74 | +-H 'Content-Type: application/json' \ |
| 75 | +-d '{ |
| 76 | + "user_prompt": "What is the latest version of Python and what are its main features?", |
| 77 | + "output_schema": { |
| 78 | + "properties": { |
| 79 | + "version": {"type": "string"}, |
| 80 | + "release_date": {"type": "string"}, |
| 81 | + "major_features": {"type": "array", "items": {"type": "string"}} |
| 82 | + }, |
| 83 | + "required": ["version", "release_date", "major_features"] |
| 84 | + } |
| 85 | +}' |
| 86 | +``` |
| 87 | + |
| 88 | +## Example Response |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "request_id": "123e4567-e89b-12d3-a456-426614174000", |
| 93 | + "status": "completed", |
| 94 | + "user_prompt": "What is the latest version of Python and what are its main features?", |
| 95 | + "result": { |
| 96 | + "version": "3.12", |
| 97 | + "release_date": "October 2, 2023", |
| 98 | + "major_features": [ |
| 99 | + "Improved error messages", |
| 100 | + "Per-interpreter GIL", |
| 101 | + "Support for the Linux perf profiler", |
| 102 | + "Faster startup time" |
| 103 | + ] |
| 104 | + }, |
| 105 | + "reference_urls": [ |
| 106 | + "https://www.python.org/downloads/", |
| 107 | + "https://docs.python.org/3.12/whatsnew/3.12.html" |
| 108 | + ], |
| 109 | + "error": "" |
| 110 | +} |
| 111 | +``` |
0 commit comments