> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapio.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Search

> Run a web search and optionally fetch each result page in the same call.



## OpenAPI

````yaml post /v1/search
openapi: 3.1.0
info:
  title: Scrapio
  version: 1.0.0
  description: >-
    Turn any URL into structured data. Fetch raw HTML, crawl sites, extract
    structured content, interact with dynamic pages, and search the web through
    one API.
  contact:
    name: Scrapio Support
    url: https://scrapio.dev
  license:
    name: Proprietary
servers:
  - url: https://api.scrapio.dev
    description: Production
  - url: http://localhost:3000
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: System
  - name: Fetch
  - name: Google
  - name: Crawl
  - name: Map
  - name: Interact
  - name: Search
  - name: Jobs
  - name: YouTube
  - name: Amazon
  - name: Walmart
paths:
  /v1/search:
    post:
      tags:
        - Search
      summary: Search the web and optionally fetch results
      description: >-
        Runs a Google search and, when `fetch_results: true`, fetches each
        result page and returns its content in the requested `output` formats
        (optionally with structured `extract`). Without `fetch_results`, only
        the ranked search results are returned. For large workflows, submit via
        `POST /v1/jobs` with `kind: "search"` instead.
      operationId: searchWorkflow
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchWorkflowRequest'
            examples:
              search_only:
                summary: Search only, no page fetch
                value:
                  query: best TypeScript frameworks
                  max_results: 5
              search_and_fetch:
                summary: Search and fetch result pages as Markdown
                value:
                  query: best TypeScript frameworks
                  max_results: 3
                  fetch_results: true
                  output:
                    - markdown
      responses:
        '200':
          description: Search (and optional fetch) completed; ranked results are returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchWorkflowResponse'
        '400':
          description: >-
            Invalid search parameters, or output/extract requested without
            fetch_results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Tenant daily credit cap exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl -X POST https://api.scrapio.dev/v1/search \
              -H "Authorization: Bearer $SCRAPIO_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{"query":"best TypeScript frameworks","max_results":5,"fetch_results":true,"output":["markdown"]}'
        - lang: Python
          label: Python
          source: |-
            import os, requests
            resp = requests.post(
                "https://api.scrapio.dev/v1/search",
                headers={"Authorization": f"Bearer {os.environ['SCRAPIO_API_KEY']}"},
                json={"query": "best TypeScript frameworks", "max_results": 5, "fetch_results": True, "output": ["markdown"]},
            )
            for r in resp.json()["result"]["results"]:
                print(r["title"], r["url"])
        - lang: JavaScript
          label: Node.js
          source: |-
            const resp = await fetch("https://api.scrapio.dev/v1/search", {
              method: "POST",
              headers: { Authorization: `Bearer ${process.env.SCRAPIO_API_KEY}`, "Content-Type": "application/json" },
              body: JSON.stringify({ query: "best TypeScript frameworks", max_results: 5, fetch_results: true, output: ["markdown"] }),
            });
            const { result } = await resp.json();
            result.results.forEach(r => console.log(r.title, r.url));
components:
  schemas:
    SearchWorkflowRequest:
      type: object
      properties:
        query:
          type: string
          minLength: 1
        provider:
          type: string
          enum:
            - google
        max_results:
          type: integer
          exclusiveMinimum: 0
          maximum: 10
        fetch_results:
          type: boolean
        output:
          minItems: 1
          type: array
          items:
            type: string
            enum:
              - html
              - markdown
              - json
              - screenshot
        extract:
          anyOf:
            - type: object
              properties:
                mode:
                  type: string
                  enum:
                    - page
              required:
                - mode
              additionalProperties: false
            - type: object
              properties:
                mode:
                  type: string
                  enum:
                    - selectors
                fields:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: object
                    properties:
                      selector:
                        type: string
                        minLength: 1
                      type:
                        type: string
                        enum:
                          - text
                          - html
                          - attr
                      attribute:
                        type: string
                        minLength: 1
                    required:
                      - selector
                      - type
                    additionalProperties: false
              required:
                - mode
                - fields
              additionalProperties: false
            - type: object
              properties:
                mode:
                  type: string
                  enum:
                    - schema
                schema:
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties:
                    type: string
              required:
                - mode
                - schema
              additionalProperties: false
            - type: object
              properties:
                mode:
                  type: string
                  enum:
                    - instruction
                instruction:
                  type: string
                  minLength: 1
              required:
                - mode
                - instruction
              additionalProperties: false
        timeout_ms:
          type: integer
          exclusiveMinimum: 0
          maximum: 300000
      required:
        - query
      additionalProperties: false
    SearchWorkflowResponse:
      type: object
      properties:
        id:
          type: string
        request_id:
          type: string
        kind:
          type: string
          enum:
            - search
        mode:
          type: string
          enum:
            - inline
        status:
          type: string
          enum:
            - completed
            - partial
        steps:
          type: array
          items:
            type: object
            properties:
              step_id:
                type: string
              type:
                type: string
              status:
                type: string
                enum:
                  - completed
                  - failed
              started_at:
                type: string
              completed_at:
                type: string
              error:
                type: object
                properties:
                  code:
                    type: string
                  message:
                    type: string
                required:
                  - code
                  - message
            required:
              - step_id
              - type
              - status
              - started_at
              - completed_at
        result:
          type: object
          properties:
            query:
              type: string
            provider:
              type: string
              enum:
                - google
            results:
              type: array
              items:
                type: object
                properties:
                  rank:
                    type: number
                  title:
                    type: string
                  url:
                    type: string
                  snippet:
                    type: string
                  status:
                    type: string
                    enum:
                      - completed
                      - partial
                      - failed
                  outputs:
                    type: object
                    propertyNames:
                      type: string
                    additionalProperties: {}
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - rank
                  - title
                  - url
                  - snippet
          required:
            - query
            - provider
            - results
        diagnostics:
          type: object
          properties:
            step_errors:
              type: array
              items:
                type: object
                properties:
                  step_id:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
                  url:
                    type: string
                required:
                  - step_id
                  - code
                  - message
          required:
            - step_errors
      required:
        - id
        - request_id
        - kind
        - mode
        - status
        - steps
        - result
        - diagnostics
    ErrorResponse:
      type: object
      properties:
        request_id:
          type: string
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
          required:
            - code
            - message
        diagnostics:
          type: object
          properties:
            outcome:
              type: string
              enum:
                - failed
            retryable:
              type: boolean
            blocked:
              type: boolean
            timed_out:
              type: boolean
          required:
            - outcome
            - retryable
          additionalProperties: false
      required:
        - request_id
        - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````