openapi: 3.0.0
info:
  title: Facebook Group Posts API
  description: |
    The Facebook Group Posts API returns the posts of a public Facebook group, up to ten on the first page and
    usually three on each later one.

    `sort_by` picks the order. `most_relevant`, the default, is Facebook's ranked view, `newest` lists the latest
    posts first, and `recent_activity` lists the posts with the latest activity first. Facebook can leave a few
    posts out of an order, and it ranks `most_relevant` anew on each request, so a busy group can repeat a post on
    a later page. Follow `pagination.next_page_token` when present, even if `posts` is empty. Pass it
    back as `next_page_token` to fetch the next page. The token identifies the group and the order on its own, so
    `url` may be omitted with it. A `next_page_token` Facebook no longer accepts answers 200 with an `error` and
    costs a credit.

    Posts carry their type, time, link, author, reactions with their breakdown by type, comment and share counts,
    and, when they hold them, text, photos, video, link preview, event details in `event`, the original of a shared post and the item they
    sell in `listing`.

    A private group, a group that does not exist or is hidden, or a share link that opens anything but a group,
    answers 200 with an `error` and costs a credit.

    **Cross-linking**: `group.link` from the Facebook Group API is a valid `url` here, and a post's `link` is a
    valid `url` for the Facebook Post and Facebook Comments APIs.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Group Posts
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_group_posts"]
            default: "facebook_group_posts"
        - name: url
          in: query
          required: false
          description: >-
            Link of the public Facebook group, such as https://www.facebook.com/groups/132851767828/, of any page
            inside it, or a facebook.com/share/ link that opens it. It is also group.link from the Facebook Group
            API. Required unless next_page_token is provided.
          schema:
            type: string
            maxLength: 2048
        - name: sort_by
          in: query
          required: false
          description: >-
            Order of the posts. most_relevant (default) is Facebook's ranked view and can repeat a post on a later
            page, newest lists the latest posts first, and recent_activity lists the posts with the latest activity
            first. With a next_page_token it must match the order the token was issued for.
          schema:
            type: string
            enum: [most_relevant, newest, recent_activity]
        - 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 has no group for the link, shows its posts to members only, has
            none left, or 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
            group, a malformed next_page_token, or a sort_by that does not match the token. 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'
        group:
          $ref: '#/components/schemas/Group'
        posts:
          type: array
          description: Posts of the group 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
    Group:
      type: object
      description: Group the posts were published in
      required: [id, link]
      properties:
        id:
          type: string
          description: Numeric id of the group
        name:
          type: string
          description: Name of the group when Facebook includes it on this page
        link:
          type: string
          format: uri
          description: URL of the group on Facebook
    Post:
      type: object
      required: [position, id, link, type, iso_date, author, reactions, comments]
      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
        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'
        iso_date:
          type: string
          format: date-time
          description: Time the post was published, in UTC
        author:
          $ref: '#/components/schemas/Author'
        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
        images:
          type: array
          description: Photos the post shows, up to five of a larger album
          items:
            $ref: '#/components/schemas/Photo'
        video:
          $ref: '#/components/schemas/Video'
        link_preview:
          $ref: '#/components/schemas/LinkPreview'
        shared_post:
          $ref: '#/components/schemas/SharedPost'
        event:
          $ref: '#/components/schemas/Event'
        listing:
          $ref: '#/components/schemas/Listing'
    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
    SharedPostAuthor:
      type: object
      description: Page or person who wrote the original post
      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
    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
    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: [link, image]
      properties:
        id:
          type: string
          description: Numeric id of the photo, for a photo on Facebook
        link:
          type: string
          format: uri
          description: URL of the photo on Facebook, or of the Marketplace item it shows
        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, 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
    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
      required: [id, link, type, author]
      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
        author:
          $ref: '#/components/schemas/SharedPostAuthor'
        images:
          type: array
          description: Photos the original post holds
          items:
            $ref: '#/components/schemas/Photo'
        video:
          $ref: '#/components/schemas/Video'
        link_preview:
          $ref: '#/components/schemas/LinkPreview'
    Event:
      type: object
      description: Event attached to the post
      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
    Listing:
      type: object
      description: Item the post sells
      required: [title]
      properties:
        title:
          type: string
          description: Title of the item
        price:
          type: string
          description: Price as Facebook shows it
        extracted_price:
          type: number
          description: Price as a number, 0 for a free item
        currency:
          type: string
          description: ISO code of the price's currency, for items listed in the group itself
        location:
          type: string
          description: Place, area or postal code the seller gives
        link:
          type: string
          format: uri
          description: URL of the item on Facebook Marketplace, for items listed there
        is_sold:
          type: boolean
          description: Whether the item is marked as sold
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Cursor for the next page in the same order
    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 group, or of the share link the search was requested with
        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: Group link the posts were requested with
        sort_by:
          type: string
          description: Order the posts were requested in
        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
