openapi: 3.0.0
info:
  title: Facebook Profile Reels API
  description: |
    The Facebook Profile Reels API returns the reels on the reels tab of a public Facebook profile or Page, up
    to ten at a time, with the text, time, author, reaction, comment, share and play counts, music and the video
    file links.

    `plays` is the number Facebook shows on each reel of the tab. Facebook rounds it, and the shares, from
    1,000 up, such as 462K.

    The first page adds a `profile` block. Each response carries a `pagination.next_page_token` while more
    reels remain. Pass it back as `next_page_token` to fetch the next page. The token identifies the profile
    on its own, so `url` may be omitted with it.

    A profile Facebook does not show publicly, a share link that opens something other than a profile, a
    profile without a public Reels tab and a `next_page_token` Facebook no longer accepts answer 200 with an `error`
    and cost a credit.

    A reel published together with other accounts lists them in `collaborators`, by `id` alone where Facebook
    names only one.

    **Cross-linking**: `post.author.link` from the Facebook Post API and `page.link` from the Facebook Business
    Page API are valid `url` values here. A reel's `link` is a valid `url` for the Facebook Post and Facebook
    Comments APIs, and its `post_id` is the `id` of the same post in the Facebook Profile Posts API.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Profile Reels
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_profile_reels"]
            default: "facebook_profile_reels"
        - name: url
          in: query
          required: false
          description: >-
            Link of the public Facebook profile or Page, such as https://www.facebook.com/NASA. profile.php,
            people, numeric id and share links are accepted, and so is the link of one of the profile's tabs.
            Required unless next_page_token is provided.
          schema:
            type: string
            maxLength: 2048
        - name: next_page_token
          in: query
          required: false
          description: >-
            Cursor for the next page, from pagination.next_page_token in a previous response. Omit it for the
            first page.
          schema:
            type: string
            maxLength: 8192
      responses:
        '200':
          description: >-
            Successful response. When Facebook shows no such profile publicly, the profile has no public Reels tab,
            or Facebook no longer accepts the next_page_token, the body carries `error` naming the reason in place
            of `reels`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: >-
            Validation Error. There is an issue with query parameters, such as a link that is not a Facebook
            profile or Page, or a next_page_token that is malformed or belongs to another profile. The search is not billed.
          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
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        profile:
          $ref: '#/components/schemas/Profile'
        reels:
          type: array
          description: Reels of the profile for this page
          items:
            $ref: '#/components/schemas/Reel'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message naming why there are no reels to show
    Profile:
      type: object
      description: The profile or Page whose reels are listed
      required: [id, name, link, avatar, is_verified]
      properties:
        id:
          type: string
          description: Facebook id of the profile
        name:
          type: string
          description: Display name of the profile
        username:
          type: string
          description: Username in the profile's link
        link:
          type: string
          format: uri
          description: URL of the profile on Facebook
        avatar:
          type: string
          format: uri
          description: URL of the profile picture
        is_verified:
          type: boolean
          description: Whether the profile is verified
        followers:
          $ref: '#/components/schemas/SocialMetric'
        cover_photo_original:
          type: string
          format: uri
          description: URL of the profile's cover photo image file
        cover_photo_link:
          type: string
          format: uri
          description: Facebook URL of the cover photo post
    SocialMetric:
      type: object
      description: The follower count Facebook shows, with the link to the list
      required: [text]
      properties:
        text:
          type: string
          description: Count as Facebook shows it, such as 28M followers
        link:
          type: string
          format: uri
          description: Facebook URL listing the followers
        count:
          type: integer
          description: Count as a number, rounded as Facebook shows it
    Reel:
      type: object
      required: [position, id, post_id, link, iso_date, author, reactions, comments, shares, plays, video]
      properties:
        position:
          type: integer
          description: Position of the reel on this page, starting at 1
        id:
          type: string
          description: Numeric id of the reel
        post_id:
          type: string
          description: Numeric id of the post that published the reel
        link:
          type: string
          format: uri
          description: URL of the reel on Facebook
        text:
          type: string
          description: Text of the reel
        hashtags:
          type: array
          description: Hashtags in the text as written, without the hash sign
          items:
            type: string
        mentions:
          type: array
          description: Pages and people tagged in the text
          items:
            $ref: '#/components/schemas/Mention'
        text_links:
          type: array
          description: Links found in the text
          items:
            type: string
            format: uri
        iso_date:
          type: string
          format: date-time
          description: Time the reel was published, in UTC
        author:
          $ref: '#/components/schemas/Author'
        collaborators:
          type: array
          description: Other Pages and people the reel was published together with
          items:
            $ref: '#/components/schemas/Collaborator'
        reactions:
          type: integer
          description: Total number of reactions
        comments:
          type: integer
          description: Number of comments, replies included
        shares:
          type: integer
          description: Number of shares, rounded by Facebook from 1,000 up
        plays:
          type: integer
          description: Number of plays Facebook shows on the reel, rounded by Facebook from 1,000 up
        music:
          $ref: '#/components/schemas/Music'
        video:
          $ref: '#/components/schemas/Video'
    Author:
      type: object
      description: Page or person who posted
      required: [id, name]
      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
    Collaborator:
      type: object
      required: [id]
      properties:
        id:
          type: string
          description: Facebook id of the collaborator
        name:
          type: string
          description: Display name of the collaborator
        avatar:
          type: string
          format: uri
          description: URL of the collaborator's profile picture
    Mention:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: Facebook id of the Page or person
        name:
          type: string
          description: Name as written in the text
        link:
          type: string
          format: uri
          description: URL of the Page or profile
    Music:
      type: object
      description: Sound the reel uses
      required: [title]
      properties:
        id:
          type: string
          description: Facebook id of the sound
        title:
          type: string
          description: Name of the sound, with its owner
        cover:
          type: string
          format: uri
          description: URL of the sound's cover image
        is_original:
          type: boolean
          description: True for custom audio, false for library music. Omitted when Facebook does not identify the soundtrack type.
    Video:
      type: object
      required: [id, permalink]
      properties:
        id:
          type: string
          description: Numeric id of the video
        permalink:
          type: string
          format: uri
          description: URL of the video or reel on Facebook
        link:
          type: string
          format: uri
          description: URL of the best video file Facebook offers for download, which can be a lower quality than it streams
        thumbnail:
          type: string
          format: uri
          description: URL of the video's cover image
        duration:
          type: number
          description: Length of the video in seconds
        width:
          type: integer
          description: Width of the video in pixels
        height:
          type: integer
          description: Height of the video in pixels
        sd_link:
          type: string
          format: uri
          description: URL of the standard-definition video file
        hd_link:
          type: string
          format: uri
          description: URL of the high-definition video file
        dash_manifest_link:
          type: string
          format: uri
          description: URL of the video's DASH manifest
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Cursor for the next page of the same list
    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 of the requested profile
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      required: [engine]
      properties:
        engine:
          type: string
          description: Search engine identifier
        url:
          type: string
          description: Profile link the reels were requested with
        next_page_token:
          type: string
          description: Cursor of the requested page
        zero_retention:
          type: boolean
          description: Whether zero data retention was requested
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
