AgentQL Query Data API

Extract structured data from web pages using AgentQL queries

OpenAPI Specification

agentql-query-data-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: AgentQL Query Data API
  description: AgentQL connects LLMs and AI agents to the entire web through natural language queries, enabling structured data extraction from web pages, documents, and browser sessions. Generated from documentation.
  version: v1
  x-generated-from: documentation
servers:
- url: https://api.agentql.com/v1
  description: AgentQL Production API
security:
- ApiKeyAuth: []
tags:
- name: Query Data
  description: Extract structured data from web pages using AgentQL queries
paths:
  /query-data:
    post:
      operationId: queryWebPageData
      summary: AgentQL Query Web Page Data
      description: Extract structured JSON data from a web page using AgentQL query language or natural language prompt. Supports URL-based and raw HTML input with configurable browser behavior.
      tags:
      - Query Data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryDataRequest'
            examples:
              QueryDataRequest200Example:
                summary: Default queryWebPageData request
                x-microcks-default: true
                value:
                  url: https://news.ycombinator.com
                  query: '{ posts[] { title link score } }'
                  params:
                    mode: standard
                    wait_for: 2000
      responses:
        '200':
          description: Successful data extraction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryDataResponse'
              examples:
                QueryWebPageData200Example:
                  summary: Default queryWebPageData 200 response
                  x-microcks-default: true
                  value:
                    data:
                      posts:
                      - title: 'Show HN: AgentQL connects AI agents to the web'
                        link: https://news.ycombinator.com/item?id=500123
                        score: 142
                    metadata:
                      request_id: req-a1b2c3d4
                      response_time_ms: 1847
        '400':
          description: Bad request — invalid query or missing required parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    ResponseMetadata:
      type: object
      description: Metadata about the API response.
      properties:
        request_id:
          type: string
          description: Unique identifier for this API request.
          example: req-a1b2c3d4
        response_time_ms:
          type: integer
          description: Time taken to complete the request in milliseconds.
          example: 1847
    QueryDataRequest:
      type: object
      description: Request body for querying data from a web page.
      properties:
        url:
          type: string
          format: uri
          description: The URL of the web page to query.
          example: https://news.ycombinator.com
        html:
          type: string
          description: Raw HTML content to query instead of a URL.
          example: <html><body><h1>Hello World</h1></body></html>
        query:
          type: string
          description: AgentQL query string for structured data extraction.
          example: '{ posts[] { title link score } }'
        prompt:
          type: string
          description: Natural language description of the data to extract (alternative to query).
          example: Extract the top 10 posts with their titles, links, and scores
        params:
          $ref: '#/components/schemas/QueryParams'
    ErrorResponse:
      type: object
      description: Error response returned when a request fails.
      properties:
        error:
          type: string
          description: Error type or code.
          example: invalid_query
        message:
          type: string
          description: Human-readable error description.
          example: The provided query is not valid AgentQL syntax.
        request_id:
          type: string
          description: Request ID for debugging.
          example: req-a1b2c3d4
    QueryDataResponse:
      type: object
      description: Response containing extracted structured data.
      properties:
        data:
          type: object
          description: Extracted data matching the structure defined in the query.
        metadata:
          $ref: '#/components/schemas/ResponseMetadata'
    QueryParams:
      type: object
      description: Optional configuration parameters for the query.
      properties:
        mode:
          type: string
          enum:
          - fast
          - standard
          description: Extraction speed mode. Fast is quicker but may miss dynamic content.
          example: standard
        wait_for:
          type: integer
          description: Milliseconds to wait for dynamic content to load before extraction.
          example: 2000
        scroll_to_bottom:
          type: boolean
          description: If true, scroll to the bottom of the page before extraction.
          example: false
        include_screenshot:
          type: boolean
          description: If true, include a base64-encoded screenshot in the response.
          example: false
        browser_profile:
          type: string
          enum:
          - light
          - stealth
          description: Browser profile to use for the request.
          example: light
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key from the AgentQL Dev Portal (https://dev.agentql.com)