openapi: 3.0.0
info:
  title: Facebook Group API
  description: |
    The Facebook Group API returns the public information of a Facebook group: its name, description, member
    count, recent activity, creation date, tags, locations, cover photo and rules.

    A public group also carries its number of admins and moderators. A private group answers with its
    information too, except for those two counts, which Facebook shows to its members only.

    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` is a valid `url` for the Facebook Group Posts API.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Group
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_group"]
            default: "facebook_group"
        - name: url
          in: query
          required: true
          description: >-
            Link of the Facebook group, such as https://www.facebook.com/groups/132851767828/, of any page inside
            it, or a facebook.com/share/ link that opens it.
          schema:
            type: string
            maxLength: 2048
      responses:
        '200':
          description: >-
            Successful response. When Facebook has no group for the link, the body carries `error` naming the
            reason in place of `group`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: >-
            Validation Error. There is an issue with query parameters, such as a missing url or a link that is
            not a Facebook group. 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'
        rules:
          type: array
          description: Rules of the group
          items:
            $ref: '#/components/schemas/Rule'
        error:
          type: string
          description: Message saying Facebook has no group for the link
    Group:
      type: object
      required: [id, name, link, is_private, members, posts_last_day, posts_last_month, created_at]
      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 on Facebook
        description:
          type: string
          description: Description of the group
        is_private:
          type: boolean
          description: Whether only members see who is in the group and what they post
        members:
          type: integer
          description: Number of members
        posts_last_day:
          type: integer
          description: Number of posts in the last day
        posts_last_month:
          type: integer
          description: Number of posts in the last month
        created_at:
          type: string
          format: date-time
          description: Time the group was created, in UTC
        admins:
          type: integer
          description: Number of admins of a public group
        moderators:
          type: integer
          description: Number of moderators of a public group
        tags:
          type: array
          description: Topics the group is tagged with
          items:
            $ref: '#/components/schemas/Tag'
        locations:
          type: array
          description: Places the group is tagged with
          items:
            $ref: '#/components/schemas/Location'
        cover_photo:
          $ref: '#/components/schemas/CoverPhoto'
    Tag:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: Facebook id of the topic
        name:
          type: string
          description: Name of the topic
    Location:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: Facebook id of the place
        name:
          type: string
          description: Name of the place
    CoverPhoto:
      type: object
      description: Cover photo of the group
      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
    Rule:
      type: object
      required: [position, title]
      properties:
        position:
          type: integer
          description: Position of the rule, starting at 1
        title:
          type: string
          description: Title of the rule
        description:
          type: string
          description: Text of the rule
    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's about page, 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 search was requested with
        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
