openapi: 3.0.0
info:
  title: Facebook Profile Events API
  description: |
    The Facebook Profile Events API returns the public events on a Facebook profile's or Page's events tab, with
    the title, date, venue, host and picture of each event.

    `time_period` picks upcoming or past events. Without it the API returns Facebook's own default, which is
    upcoming events, or past ones when nothing is upcoming. `search_information.time_period` says which list
    the events come from. Upcoming events come soonest first and past ones most recent first.

    The first page holds up to eight events and adds a `profile` block, and later pages hold up to ten. Each
    response carries a `pagination.next_page_token` while more events remain. Pass it back as
    `next_page_token` to fetch the next page. The token identifies the profile and the list on its own, so
    `url` and `time_period` 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 public events in the requested list and a `next_page_token` Facebook no longer accepts
    answer 200 with an `error` and cost a credit.

    **Cross-linking**: `post.author.link` from the Facebook Post API, `page.link` from the Facebook Business Page
    API and an event's `host.link` are valid `url` values here.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Profile Events
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_profile_events"]
            default: "facebook_profile_events"
        - 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
          in: query
          required: false
          description: >-
            Which events to list. upcoming lists the events still to come and past lists the ones that are over.
            Without it Facebook's own default is used, upcoming events or past ones when nothing is upcoming.
            With a next_page_token it must match the list the token was issued for.
          schema:
            type: string
            enum: [upcoming, past]
        - 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 events
            in the requested list, or Facebook no longer accepts the next_page_token, the body carries `error`
            naming the reason in place of `events`.
          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, an unsupported time_period, or a next_page_token that is malformed or does not match
            the url 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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        profile:
          $ref: '#/components/schemas/Profile'
        events:
          type: array
          description: Events of the profile for this page
          items:
            $ref: '#/components/schemas/Event'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message naming why there are no events to show
    SearchInformation:
      type: object
      required: [time_period]
      properties:
        time_period:
          type: string
          enum: [upcoming, past]
          description: Which list the events come from
    Profile:
      type: object
      description: The profile or Page whose events 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
    Event:
      type: object
      required: [position, id, title, link, date, iso_date, is_past, is_canceled, is_happening_now, is_online, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the event on this page, starting at 1
        id:
          type: string
          description: Numeric id of the event
        title:
          type: string
          description: Title of the event
        link:
          type: string
          format: uri
          description: URL of the event on Facebook
        date:
          type: string
          description: 'Date label as Facebook shows it, in the event''s own time zone (e.g. "Fri, Apr 2, 2027 at 4:30 PM MDT", or "Happening now" for an event under way)'
        iso_date:
          type: string
          format: date-time
          description: Start time of the event, in UTC
        venue:
          $ref: '#/components/schemas/Venue'
        host:
          $ref: '#/components/schemas/Host'
        is_past:
          type: boolean
          description: Whether the event is over
        is_canceled:
          type: boolean
          description: Whether the event was canceled
        is_happening_now:
          type: boolean
          description: Whether the event is going on at the moment
        is_online:
          type: boolean
          description: Whether the event takes place online
        online_type:
          type: string
          description: Where the online event takes place, one of fb_live, third_party, messenger_room or other
        online_link:
          type: string
          description: Link of an online event held outside Facebook
        parent_event_id:
          type: string
          description: Numeric id of the recurring event this date belongs to
        live_videos:
          type: array
          description: Live videos broadcast as part of the event
          items:
            $ref: '#/components/schemas/LiveVideo'
        thumbnail:
          type: string
          format: uri
          description: URL of the event's picture
    Venue:
      type: object
      description: Where the event takes place
      properties:
        id:
          type: string
          description: Facebook id of the venue's Page
        name:
          type: string
          description: Name or address of the venue as the host wrote it
        city:
          type: string
          description: City of the venue
    Host:
      type: object
      description: The profile or Page that created the event
      required: [id, name]
      properties:
        id:
          type: string
          description: Facebook id of the host
        name:
          type: string
          description: Display name of the host
        username:
          type: string
          description: Username in the host's profile link
        link:
          type: string
          format: uri
          description: URL of the host's Facebook profile or Page
    LiveVideo:
      type: object
      required: [id]
      properties:
        id:
          type: string
          description: Numeric id of the video
        link:
          type: string
          format: uri
          description: URL of the video on Facebook
        is_live:
          type: boolean
          description: Whether the video is on air at the moment
    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 events were requested with
        time_period:
          type: string
          description: Which events were requested
        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
