|
71 | 71 | }, |
72 | 72 | "failureCategory": { |
73 | 73 | "type": "string", |
74 | | - "description": "`/crawl` and `/extract`: why the page could not be read, e.g. `NOT_FOUND`, `GONE`, `FORBIDDEN`, `AUTH_REQUIRED`, `BLOCKED`, `RATE_LIMITED`, `DNS_NOT_FOUND`, `TARGET_UNREACHABLE`, `TIMEOUT`, `QUALITY_CHECK`." |
| 74 | + "description": "`/crawl` and `/extract`: why the page could not be read, e.g. `NOT_FOUND`, `GONE`, `FORBIDDEN`, `AUTH_REQUIRED`, `BLOCKED`, `RATE_LIMITED`, `DNS_NOT_FOUND`, `TARGET_UNREACHABLE`, `TARGET_BAD_REQUEST`, `TIMEOUT`, `QUALITY_CHECK`." |
75 | 75 | }, |
76 | 76 | "upstreamStatus": { |
77 | 77 | "type": "integer", |
|
501 | 501 | "properties": { |
502 | 502 | "url": { |
503 | 503 | "type": "string", |
504 | | - "format": "uri" |
| 504 | + "format": "uri", |
| 505 | + "description": "The webpage to extract data from." |
505 | 506 | }, |
506 | 507 | "prompt": { |
507 | | - "type": "string" |
| 508 | + "type": "string", |
| 509 | + "minLength": 1, |
| 510 | + "description": "Natural-language instructions: what to extract from the page, e.g. \"Extract the product name and price.\"" |
508 | 511 | }, |
509 | 512 | "response_format": { |
510 | 513 | "type": "object", |
511 | | - "additionalProperties": {} |
| 514 | + "properties": { |
| 515 | + "type": { |
| 516 | + "type": "string", |
| 517 | + "enum": [ |
| 518 | + "json_schema" |
| 519 | + ] |
| 520 | + }, |
| 521 | + "json_schema": { |
| 522 | + "type": "object", |
| 523 | + "additionalProperties": {}, |
| 524 | + "description": "The JSON Schema the result must follow, e.g. {\"type\": \"object\", \"properties\": {\"title\": {\"type\": \"string\"}}}. Pass the schema itself, not an object wrapping it under name/schema." |
| 525 | + } |
| 526 | + }, |
| 527 | + "required": [ |
| 528 | + "type", |
| 529 | + "json_schema" |
| 530 | + ], |
| 531 | + "additionalProperties": false, |
| 532 | + "description": "Shape of the result. Wrap your JSON Schema as {\"type\": \"json_schema\", \"json_schema\": <schema>}." |
512 | 533 | } |
513 | 534 | }, |
514 | 535 | "required": [ |
515 | | - "url" |
| 536 | + "url", |
| 537 | + "prompt", |
| 538 | + "response_format" |
516 | 539 | ], |
517 | 540 | "additionalProperties": false |
518 | 541 | }, |
|
3270 | 3293 | "post": { |
3271 | 3294 | "operationId": "extract", |
3272 | 3295 | "summary": "Extract structured content from a URL", |
3273 | | - "description": "Pull structured data out of a single webpage using a natural-language prompt and a JSON schema you supply. Use it when you need specific fields — prices, specifications, contact details — rather than the whole document; when you want the full text, use POST /crawl. Costs 10 credits per request.", |
| 3296 | + "description": "Pull structured data out of a single webpage using a natural-language prompt and a JSON schema you supply; both are required, and a request missing either returns 422 with the fields to fix. Use it when you need specific fields — prices, specifications, contact details — rather than the whole document; when you want the full text, use POST /crawl. Costs 10 credits per request.", |
3274 | 3297 | "tags": [ |
3275 | 3298 | "Crawl" |
3276 | 3299 | ], |
|
3279 | 3302 | "id": "js", |
3280 | 3303 | "lang": "ts", |
3281 | 3304 | "label": "TypeScript SDK", |
3282 | | - "source": "import { Search1API } from '@search1api/client';\n\nconst client = new Search1API();\nconst response = await client.extract('https://example.com', {\n prompt: 'Extract the page title and description.',\n});\n\nconsole.log(response);" |
| 3305 | + "source": "import { Search1API } from '@search1api/client';\n\nconst client = new Search1API();\nconst response = await client.extract('https://example.com', {\n prompt: 'Extract the page title and description.',\n responseFormat: {\n type: 'json_schema',\n json_schema: {\n type: 'object',\n properties: {\n title: { type: 'string' },\n description: { type: 'string' },\n },\n },\n },\n});\n\nconsole.log(response.results);" |
3283 | 3306 | }, |
3284 | 3307 | { |
3285 | 3308 | "id": "python", |
3286 | 3309 | "lang": "python", |
3287 | 3310 | "label": "Python SDK", |
3288 | | - "source": "from search1api import Search1API\n\nclient = Search1API()\nresponse = client.extract(\n \"https://example.com\",\n prompt=\"Extract the page title and description.\",\n)\n\nprint(response)" |
| 3311 | + "source": "from search1api import Search1API\n\nclient = Search1API()\nresponse = client.extract(\n \"https://example.com\",\n prompt=\"Extract the page title and description.\",\n response_format={\n \"type\": \"json_schema\",\n \"json_schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\"type\": \"string\"},\n \"description\": {\"type\": \"string\"},\n },\n },\n },\n)\n\nprint(response[\"results\"])" |
3289 | 3312 | } |
3290 | 3313 | ], |
3291 | 3314 | "responses": { |
|
3411 | 3434 | "properties": { |
3412 | 3435 | "url": { |
3413 | 3436 | "type": "string", |
3414 | | - "format": "uri" |
| 3437 | + "format": "uri", |
| 3438 | + "description": "The webpage to extract data from." |
3415 | 3439 | }, |
3416 | 3440 | "prompt": { |
3417 | | - "type": "string" |
| 3441 | + "type": "string", |
| 3442 | + "minLength": 1, |
| 3443 | + "description": "Natural-language instructions: what to extract from the page, e.g. \"Extract the product name and price.\"" |
3418 | 3444 | }, |
3419 | 3445 | "response_format": { |
3420 | 3446 | "type": "object", |
3421 | | - "additionalProperties": {} |
| 3447 | + "properties": { |
| 3448 | + "type": { |
| 3449 | + "type": "string", |
| 3450 | + "enum": [ |
| 3451 | + "json_schema" |
| 3452 | + ] |
| 3453 | + }, |
| 3454 | + "json_schema": { |
| 3455 | + "type": "object", |
| 3456 | + "additionalProperties": {}, |
| 3457 | + "description": "The JSON Schema the result must follow, e.g. {\"type\": \"object\", \"properties\": {\"title\": {\"type\": \"string\"}}}. Pass the schema itself, not an object wrapping it under name/schema." |
| 3458 | + } |
| 3459 | + }, |
| 3460 | + "required": [ |
| 3461 | + "type", |
| 3462 | + "json_schema" |
| 3463 | + ], |
| 3464 | + "additionalProperties": false, |
| 3465 | + "description": "Shape of the result. Wrap your JSON Schema as {\"type\": \"json_schema\", \"json_schema\": <schema>}." |
3422 | 3466 | } |
3423 | 3467 | }, |
3424 | 3468 | "required": [ |
3425 | | - "url" |
| 3469 | + "url", |
| 3470 | + "prompt", |
| 3471 | + "response_format" |
3426 | 3472 | ], |
3427 | 3473 | "additionalProperties": false |
| 3474 | + }, |
| 3475 | + "examples": { |
| 3476 | + "pageSummary": { |
| 3477 | + "summary": "Title and description", |
| 3478 | + "description": "Wrap the JSON Schema of the result as {\"type\": \"json_schema\", \"json_schema\": <schema>}.", |
| 3479 | + "value": { |
| 3480 | + "url": "https://example.com", |
| 3481 | + "prompt": "Extract the page title and description.", |
| 3482 | + "response_format": { |
| 3483 | + "type": "json_schema", |
| 3484 | + "json_schema": { |
| 3485 | + "type": "object", |
| 3486 | + "properties": { |
| 3487 | + "title": { |
| 3488 | + "type": "string" |
| 3489 | + }, |
| 3490 | + "description": { |
| 3491 | + "type": "string" |
| 3492 | + } |
| 3493 | + }, |
| 3494 | + "required": [ |
| 3495 | + "title" |
| 3496 | + ] |
| 3497 | + } |
| 3498 | + } |
| 3499 | + } |
| 3500 | + } |
3428 | 3501 | } |
3429 | 3502 | } |
3430 | 3503 | } |
|
0 commit comments