openapi: 3.0.0
info:
  title: Facebook Transcripts API
  description: >-
    Read native timed captions or untimed text provided by Facebook. A confirmed absence costs one credit and returns
    an error.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Facebook Transcripts
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Search engine identifier
        schema:
          type: string
          enum:
          - facebook_transcripts
          default: facebook_transcripts
      - name: video_id
        in: query
        required: true
        description: Numeric ID of the public Facebook video or reel.
        schema:
          type: string
          pattern: "^[1-9][0-9]{0,18}$"
      responses:
        '200':
          description: >-
            Read native timed captions or untimed text provided by Facebook. A confirmed absence costs one credit
            and returns an error.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/SearchResponse"
        '400':
          description: The request parameters are invalid.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '429':
          description: >-
            Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan
            or waiting for the limit to reset.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
        '503':
          description: Timeout, or Facebook answered but returned nothing usable. The search is not billed.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      required:
      - search_metadata
      - search_parameters
      properties:
        search_metadata:
          "$ref": "#/components/schemas/SearchMetadata"
        search_parameters:
          "$ref": "#/components/schemas/SearchParameters"
        source:
          type: string
          description: Kind of text provided by Facebook.
          enum:
          - native_captions
          - untimed_text
        locale:
          type: string
          description: Facebook locale of the selected caption track.
        transcripts:
          type: array
          items:
            type: object
            required:
            - text
            properties:
              text:
                type: string
                description: Facebook transcript text.
              start:
                type: number
                description: Cue start time in seconds.
              duration:
                type: number
                description: Cue duration in seconds.
          description: Caption cues or a single untimed text entry.
        error:
          type: string
          description: Message when Facebook has no public transcript.
      oneOf:
        - required: [source, transcripts]
          properties:
            source:
              enum: [native_captions]
            transcripts:
              type: array
              minItems: 1
              items:
                type: object
                required: [text, start, duration]
        - required: [source, transcripts]
          properties:
            source:
              enum: [untimed_text]
            transcripts:
              type: array
              minItems: 1
              maxItems: 1
              items:
                type: object
                required: [text]
                properties:
                  text:
                    type: string
                additionalProperties: false
        - required: [error]
    SearchMetadata:
      type: object
      required:
      - status
      - created_at
      properties:
        id:
          type: string
          description: Unique identifier for the search request, absent when zero_retention is set
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: Facebook URL for this search
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    ErrorResponse:
      type: object
      required:
      - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
    SearchParameters:
      type: object
      required:
      - engine
      properties:
        engine:
          type: string
          description: Search engine identifier.
          enum:
          - facebook_transcripts
        video_id:
          type: string
          description: Numeric ID of the public Facebook video or reel.
          pattern: "^[1-9][0-9]{0,18}$"
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested.
