openapi: 3.0.0
info:
  title: Facebook Video Search API
  description: Find public Facebook videos and reels with a keyword query, as Facebook lists them to visitors who are not logged in. Results can include recommendations.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Facebook Video Search
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Search engine identifier
        schema:
          type: string
          enum:
          - facebook_video_search
          default: facebook_video_search
      - name: q
        in: query
        required: true
        description: Keyword query.
        schema:
          type: string
          minLength: 1
          maxLength: 256
      responses:
        '200':
          description: Find public Facebook videos and reels with a keyword query. Results can include recommendations.
          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
      - videos
      properties:
        search_metadata:
          "$ref": "#/components/schemas/SearchMetadata"
        search_parameters:
          "$ref": "#/components/schemas/SearchParameters"
        videos:
          type: array
          items:
            "$ref": "#/components/schemas/Video"
          description: Videos Facebook lists for the query.
    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
        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_video_search
        q:
          type: string
          description: Keyword query.
          minLength: 1
          maxLength: 256
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested.
    Author:
      type: object
      description: Page or person who posted
      properties:
        id:
          type: string
          description: Facebook id of the author
        name:
          type: string
          description: Display name of the author
        username:
          type: string
          description: Username in the author's profile link
        link:
          type: string
          format: uri
          description: URL of the author's Facebook profile or Page
        avatar:
          type: string
          format: uri
          description: URL of the author's profile picture
        is_verified:
          type: boolean
          description: Whether the author's Page or profile is verified
    Video:
      type: object
      required:
      - position
      - id
      - link
      properties:
        position:
          type: integer
          description: Position on this page.
        id:
          type: string
          description: Facebook video ID.
        link:
          type: string
          description: Link to the public video.
          format: uri
        duration:
          type: number
          description: Video duration in seconds.
        thumbnail:
          type: string
          description: Preview image URL.
        author:
          "$ref": "#/components/schemas/Author"
        title:
          type: string
          description: Title displayed on the video card.
        text:
          type: string
          description: Text of the video post.
        iso_date:
          type: string
          description: Publication date in UTC.
          format: date-time
        views:
          type: integer
          description: Number of views displayed for the video.
        comments:
          type: integer
          description: Number of comments displayed for the video.
        reactions:
          type: integer
          description: Number of reactions displayed for the video.
        shares:
          type: integer
          description: Number of shares displayed for the video.
