> ## 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 tweets

> Search X for tweets matching a query, sorted by top or latest.



## OpenAPI

````yaml get /v1/twitter/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
security:
  - bearerAuth: []
tags:
  - name: System
  - name: Fetch
  - name: Crawl
  - name: Map
  - name: Interact
  - name: Search
  - name: Google
  - name: Fast Search
  - name: Jobs
  - name: YouTube
  - name: Amazon
  - name: Walmart
  - name: Booking
  - name: Agoda
  - name: Airbnb
  - name: AutoTrader
  - name: ChatGPT
  - name: Perplexity
  - name: Gemini
  - name: Bing
  - name: Reddit
  - name: Instagram
  - name: Twitter
  - name: Facebook
  - name: Hacker News
  - name: GitHub
  - name: TikTok
  - name: Apple App Store
  - name: Target
  - name: Monitors
paths:
  /v1/twitter/search:
    get:
      tags:
        - Twitter
      summary: Search tweets
      description: >-
        Searches X for tweets matching a query, sorted by `top` (default,
        high-engagement) or `latest` (real-time). Drives a real Chrome browser
        session (Patchright) against X's own search results page and passively
        captures the response, since X requires a signed
        `x-client-transaction-id` header a plain HTTP request can't produce for
        this specific endpoint. Slower than every other Twitter/X endpoint —
        typically 15-20s, since it renders a real page. Requires a Starter plan
        or higher.
      operationId: getTwitterSearch
      parameters:
        - name: query
          in: query
          required: true
          schema:
            type: string
            minLength: 1
        - name: sort
          in: query
          required: false
          schema:
            default: top
            type: string
            enum:
              - top
              - latest
      responses:
        '200':
          description: Matching tweets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TwitterSearchResponse'
        '400':
          description: Missing query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Twitter/X dedicated endpoints require a Starter plan or higher.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Daily credit cap exceeded, or X rate-limited the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: X's search UI never produced a matching response in time.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: The X execution backend (browser automation) is unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: >-
            curl "https://api.scrapio.dev/v1/twitter/search?query=nasa&sort=top"
            \
              -H "Authorization: Bearer $SCRAPIO_API_KEY"
components:
  schemas:
    TwitterSearchResponse:
      type: object
      properties:
        provider:
          type: string
          enum:
            - twitter
        request_id:
          type: string
        query_context:
          type: object
          properties:
            query:
              type: string
            sort:
              type: string
              enum:
                - top
                - latest
          required:
            - query
            - sort
          additionalProperties: false
        results:
          type: array
          items:
            type: object
            properties:
              id:
                anyOf:
                  - type: string
                  - type: 'null'
              url:
                anyOf:
                  - type: string
                  - type: 'null'
              text:
                anyOf:
                  - type: string
                  - type: 'null'
              created_at:
                anyOf:
                  - type: string
                  - type: 'null'
              author:
                type: object
                properties:
                  username:
                    anyOf:
                      - type: string
                      - type: 'null'
                  display_name:
                    anyOf:
                      - type: string
                      - type: 'null'
                  avatar_url:
                    anyOf:
                      - type: string
                      - type: 'null'
                required:
                  - username
                  - display_name
                  - avatar_url
                additionalProperties: false
              stats:
                type: object
                properties:
                  likes:
                    anyOf:
                      - type: integer
                        minimum: 0
                        maximum: 9007199254740991
                      - type: 'null'
                  retweets:
                    anyOf:
                      - type: integer
                        minimum: 0
                        maximum: 9007199254740991
                      - type: 'null'
                  replies:
                    anyOf:
                      - type: integer
                        minimum: 0
                        maximum: 9007199254740991
                      - type: 'null'
                  views:
                    anyOf:
                      - type: integer
                        minimum: 0
                        maximum: 9007199254740991
                      - type: 'null'
                required:
                  - likes
                  - retweets
                  - replies
                  - views
                additionalProperties: false
              media:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      anyOf:
                        - type: string
                          enum:
                            - photo
                            - video
                            - gif
                        - type: 'null'
                    url:
                      anyOf:
                        - type: string
                        - type: 'null'
                  required:
                    - type
                    - url
                  additionalProperties: false
              is_reply:
                anyOf:
                  - type: boolean
                  - type: 'null'
              is_retweet:
                anyOf:
                  - type: boolean
                  - type: 'null'
            required:
              - id
              - url
              - text
              - created_at
              - author
              - stats
              - media
              - is_reply
              - is_retweet
            additionalProperties: false
      required:
        - provider
        - request_id
        - query_context
        - results
      additionalProperties: false
    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

````