openapi: 3.0.0
info:
  title: Facebook Profile Posts API
  description: |
    The Facebook Profile Posts API returns the posts on the timeline of a public Facebook profile or Page,
    newest first, with the text, time, author, reactions by type, comment and share counts, photos, video with
    its views and plays, link preview, event or shared post.

    The first page lists up to ten posts and adds a `profile` block, and later pages list up to nine. Each
    response carries a `pagination.next_page_token` while more posts remain. Pass it back as `next_page_token`
    to fetch the next page. The token identifies the profile and the time period on its own, so the other
    parameters may be omitted with it. Facebook can leave a post out for some visitors, so two requests for the
    same page can differ by a post.

    `time_period_min` and `time_period_max` keep the list to the days between them. A post its author backdated
    belongs to the day it was backdated to, which is `backdated_iso_date`. With a time period the first page
    lists up to nine posts.

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

    A post's `media_count` is the number of photos and videos its album holds. `images` and `videos` list the
    ones the timeline shows, which can be fewer.

    **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 post's `link` is a valid `url` for the Facebook Post and Facebook
    Comments APIs unless its `type` is `event`.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Profile Posts
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_profile_posts"]
            default: "facebook_profile_posts"
        - 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: time_period_min
          in: query
          required: false
          description: >-
            First day of the time period the posts appear under, as YYYY-MM-DD or MM/DD/YYYY, in UTC, from 1905 to
            2037. It can be used alone or with time_period_max, and must match the token when one is sent.
          schema:
            type: string
            maxLength: 10
        - name: time_period_max
          in: query
          required: false
          description: >-
            Last day of the time period the posts appear under, as YYYY-MM-DD or MM/DD/YYYY, in UTC, from 1905 to
            2037. It can be used alone or with time_period_min, must not be before it, and must match the token
            when one is sent.
          schema:
            type: string
            maxLength: 10
        - 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 or the time period has no public posts,
            or Facebook no longer accepts the next_page_token, the body carries `error` naming the reason in place
            of `posts`.
          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, a time period that is not a date
            or ends before it begins, or a next_page_token that is malformed or belongs to another profile or time
            period. 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'
        posts:
          type: array
          description: Posts of the profile for this page
          items:
            $ref: '#/components/schemas/Post'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message naming why there are no posts to show
    Profile:
      type: object
      description: The profile or Page whose posts 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
    Post:
      type: object
      required: [position, id, link, type, iso_date, author, reactions, comments, shares]
      properties:
        position:
          type: integer
          description: Position of the post on this page, starting at 1
        id:
          type: string
          description: Numeric id of the post
        link:
          type: string
          format: uri
          description: URL of the post on Facebook, or of the event it announces
        type:
          type: string
          enum: [text, photo, carousel, video, reel, link, shared, event]
          description: Kind of post, read from what it holds
        text:
          type: string
          description: Text of the post
        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 post was published, in UTC
        author:
          $ref: '#/components/schemas/Author'
        collaborators:
          type: array
          description: Other Pages and people the post was published together with
          items:
            $ref: '#/components/schemas/Author'
        group:
          $ref: '#/components/schemas/Group'
        reactions:
          type: integer
          description: Total number of reactions
        reactions_breakdown:
          $ref: '#/components/schemas/ReactionsBreakdown'
        comments:
          type: integer
          description: Number of comments, replies included
        shares:
          type: integer
          description: Number of shares
        views:
          type: integer
          description: Number of views of a video or reel
        plays:
          type: integer
          description: Number of plays of a video or reel
        backdated_iso_date:
          type: string
          format: date-time
          description: Time the author backdated the post to, in UTC
        media_count:
          type: integer
          description: Number of photos and videos in the album, which can be more than images and videos list
        images:
          type: array
          description: Photos the post holds
          items:
            $ref: '#/components/schemas/Photo'
        video:
          $ref: '#/components/schemas/Video'
        videos:
          type: array
          description: Videos of an album
          items:
            $ref: '#/components/schemas/Video'
        link_preview:
          $ref: '#/components/schemas/LinkPreview'
        shared_post:
          $ref: '#/components/schemas/SharedPost'
        event:
          $ref: '#/components/schemas/Event'
        preview_comments:
          type: array
          description: Comments Facebook shows under the post
          items:
            $ref: '#/components/schemas/PreviewComment'
    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
    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
    Group:
      type: object
      description: Group the post was published in
      required: [id, name, link]
      properties:
        id:
          type: string
          description: Numeric id of the group
        name:
          type: string
          description: Name of the group
        link:
          type: string
          format: uri
          description: URL of the group
    ReactionsBreakdown:
      type: object
      description: Reactions by type, for the types the post received
      properties:
        like:
          type: integer
          description: Like reactions
        love:
          type: integer
          description: Love reactions
        care:
          type: integer
          description: Care reactions
        haha:
          type: integer
          description: Haha reactions
        wow:
          type: integer
          description: Wow reactions
        sad:
          type: integer
          description: Sad reactions
        angry:
          type: integer
          description: Angry reactions
    Photo:
      type: object
      required: [id, link, image]
      properties:
        id:
          type: string
          description: Numeric id of the photo
        link:
          type: string
          format: uri
          description: URL of the photo on Facebook
        image:
          type: string
          format: uri
          description: URL of the image file
        width:
          type: integer
          description: Width of the image in pixels
        height:
          type: integer
          description: Height of the image in pixels
        accessibility_caption:
          type: string
          description: Description of the image that Facebook gives screen readers
    Video:
      type: object
      required: [id]
      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
    LinkPreview:
      type: object
      description: Preview of the web page the post links to
      required: [link]
      properties:
        title:
          type: string
          description: Title of the linked page
        link:
          type: string
          format: uri
          description: URL of the linked page
        source:
          type: string
          description: Domain of the linked page
        description:
          type: string
          description: Summary of the linked page
        thumbnail:
          type: string
          format: uri
          description: URL of the preview image
    SharedPost:
      type: object
      description: Original post that this post shares
      properties:
        id:
          type: string
          description: Numeric id of the original post
        link:
          type: string
          format: uri
          description: URL of the original post
        type:
          type: string
          enum: [text, photo, carousel, video, reel, link, shared]
          description: Kind of the original post
        text:
          type: string
          description: Text of the original post
        hashtags:
          type: array
          description: Hashtags in the original post's text
          items:
            type: string
        mentions:
          type: array
          description: Pages and people tagged in the original post's text
          items:
            $ref: '#/components/schemas/Mention'
        text_links:
          type: array
          description: Links found in the original post's text
          items:
            type: string
            format: uri
        author:
          $ref: '#/components/schemas/Author'
        group:
          $ref: '#/components/schemas/Group'
        media_count:
          type: integer
          description: Number of photos and videos in the album, which can be more than images and videos list
        images:
          type: array
          description: Photos the original post holds
          items:
            $ref: '#/components/schemas/Photo'
        video:
          $ref: '#/components/schemas/Video'
        videos:
          type: array
          description: Videos of an album
          items:
            $ref: '#/components/schemas/Video'
        link_preview:
          $ref: '#/components/schemas/LinkPreview'
    Event:
      type: object
      description: Event the post announces
      required: [id, title, link]
      properties:
        id:
          type: string
          description: Numeric id of the event
        title:
          type: string
          description: Name of the event
        link:
          type: string
          format: uri
          description: URL of the event on Facebook
        date:
          type: string
          description: Date and time of the event as Facebook writes it
        venue:
          $ref: '#/components/schemas/Venue'
        attendance:
          type: string
          description: How many people are going to the event or interested in it, as Facebook writes it
        is_canceled:
          type: boolean
          description: Whether the event was canceled
        thumbnail:
          type: string
          format: uri
          description: URL of the event's picture
    Venue:
      type: object
      description: Place of the event
      properties:
        id:
          type: string
          description: Facebook id of the place's Page
        name:
          type: string
          description: Name or address of the place
        city:
          type: string
          description: City of the place
    PreviewComment:
      type: object
      required: [position, id, iso_date, link, author, reactions, replies]
      properties:
        position:
          type: integer
          description: Position of the comment under the post, starting at 1
        id:
          type: string
          description: Numeric id of the comment
        text:
          type: string
          description: Text of the comment
        mentions:
          type: array
          description: Pages and people tagged in the comment
          items:
            $ref: '#/components/schemas/Mention'
        image:
          type: string
          format: uri
          description: URL of the photo, sticker or GIF the comment was posted with
        iso_date:
          type: string
          format: date-time
          description: Time the comment was posted, in UTC
        link:
          type: string
          format: uri
          description: URL of the comment on Facebook
        author:
          $ref: '#/components/schemas/CommentAuthor'
        reactions:
          type: integer
          description: Total number of reactions to the comment
        reactions_breakdown:
          $ref: '#/components/schemas/ReactionsBreakdown'
        replies:
          type: integer
          description: Number of replies to the comment
    CommentAuthor:
      type: object
      description: Page or person who wrote the comment
      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
    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 posts were requested with
        time_period_min:
          type: string
          description: First day of the requested time period
        time_period_max:
          type: string
          description: Last day of the requested time period
        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
