openapi: 3.0.0
info:
  title: Facebook Event API
  description: |
    The Facebook Event API returns the public page of one Facebook event: its title, date and time with the end
    and the timezone, description and the links in it, venue with address, city and coordinates, hosts,
    performers, categories, ticket link and price, the number of people who responded, and whether it is past,
    canceled or online. An event broadcast on Facebook adds its live videos. A recurring event's occurrence adds
    the series it belongs to, the number of occurrences and the nearest other dates.

    Pass the event as `event_id` or `url`. `url` takes an event link in any of its forms (with or without the
    venue and title in the path, a recurring event's occurrence, `event_time_id`), `fb.me/e/` invite links and
    `facebook.com/share/` links. A recurring event's own link opens its next occurrence, or its last one once the
    series is over, as it does on Facebook.

    An event Facebook does not show publicly (removed, private or never created) and a share link that opens
    something other than an event answer 200 with an `error` and cost a credit.

    **Cross-linking**: an event's `link` from the Facebook Events Search API or the Facebook Profile Events API
    is a valid `url`, and its `id` a valid `event_id`. `venue.location_id` is a valid `location_id` for the
    Facebook Events Search API. The `link` of a host that is a Page or a person is a valid `url` for the Facebook
    profile APIs. A host that is a group links to the group, which those APIs do not take.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Facebook Event
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine identifier
          schema:
            type: string
            enum: ["facebook_event"]
            default: "facebook_event"
        - name: event_id
          in: query
          required: false
          description: >-
            Numeric id of the public Facebook event, such as 1004917405909623. Required unless url is provided,
            and not sent together with url.
          schema:
            type: string
            pattern: '^\s*[1-9][0-9]{0,18}\s*$'
        - name: url
          in: query
          required: false
          description: >-
            Link of the public Facebook event, such as https://www.facebook.com/events/1004917405909623/.
            fb.me/e/ invite links and facebook.com/share/ links are accepted. Required unless event_id is
            provided, and not sent together with event_id.
          schema:
            type: string
            maxLength: 2048
      responses:
        '200':
          description: >-
            Successful response. When Facebook shows no such event publicly, or a share link opens something
            other than an event, the body carries `error` in place of `event`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: >-
            Validation Error. There is an issue with query parameters, such as an event_id that is not a number,
            a link that is not a Facebook event, or both parameters at once. 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'
        event:
          $ref: '#/components/schemas/Event'
        error:
          type: string
          description: Message naming why there is no event to show
    Event:
      type: object
      required: [id]
      properties:
        id:
          type: string
          description: Numeric id of the event, or of the occurrence for a recurring 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 and time as Facebook shows them, in the event's own timezone
        iso_date:
          type: string
          format: date-time
          description: Time the event starts, in UTC
        end_iso_date:
          type: string
          format: date-time
          description: Time the event ends, in UTC
        duration:
          type: string
          description: Length of the event as Facebook shows it, such as 2 hr 30 min
        timezone:
          type: string
          description: Abbreviation of the event's timezone, such as CST or UTC+01
        description:
          type: string
          description: Description the hosts wrote
        description_links:
          type: array
          description: Links found in the description
          items:
            type: string
            format: uri
        venue:
          $ref: '#/components/schemas/Venue'
        hosts:
          type: array
          description: Pages, people and groups hosting the event
          items:
            $ref: '#/components/schemas/Person'
        group:
          $ref: '#/components/schemas/Group'
        performers:
          type: array
          description: Artists and other Pages Facebook lists as performing
          items:
            $ref: '#/components/schemas/Person'
        categories:
          type: array
          description: Categories Facebook files the event under
          items:
            $ref: '#/components/schemas/Category'
        tickets:
          $ref: '#/components/schemas/Tickets'
        responses:
          type: integer
          description: Number of people who said they are interested or going
        is_past:
          type: boolean
          description: Whether the event is over
        is_canceled:
          type: boolean
          description: Whether the hosts canceled the event
        is_online:
          type: boolean
          description: Whether the event takes place online
        online_type:
          type: string
          description: How an online event is held, in lowercase, such as fb_live
        online_link:
          type: string
          format: uri
          description: Link of the outside service an online event is held on
        live_videos:
          type: array
          description: Live videos broadcast as part of the event
          items:
            $ref: '#/components/schemas/LiveVideo'
        parent_event_id:
          type: string
          description: Id of the recurring event this occurrence belongs to
        occurrences:
          type: integer
          description: Number of occurrences of the recurring event
        other_occurrences:
          type: array
          description: Occurrences of the recurring event near this one, in date order
          items:
            $ref: '#/components/schemas/Occurrence'
        has_date_changed:
          type: boolean
          description: Whether the hosts changed the date after publishing the event
        has_title_changed:
          type: boolean
          description: Whether the hosts changed the title after publishing the event
        thumbnail:
          type: string
          format: uri
          description: URL of the event's cover picture
    Venue:
      type: object
      properties:
        id:
          type: string
          description: Facebook id of the venue's Page
        name:
          type: string
          description: Name or address of the venue as the hosts entered it
        link:
          type: string
          format: uri
          description: URL of the venue's Page on Facebook
        address:
          type: string
          description: Address of the venue on one line
        city:
          type: string
          description: City of the venue
        location_id:
          type: string
          description: Facebook id of the city, usable as location_id in the Facebook Events Search API
        gps_coordinates:
          type: object
          required: [latitude, longitude]
          properties:
            latitude:
              type: number
              description: Latitude of the venue
            longitude:
              type: number
              description: Longitude of the venue
    Person:
      type: object
      required: [id, name]
      properties:
        id:
          type: string
          description: Facebook id of the Page, person or group
        name:
          type: string
          description: Display name
        username:
          type: string
          description: Username in the profile's link
        link:
          type: string
          format: uri
          description: URL of the profile on Facebook
        is_verified:
          type: boolean
          description: Whether the profile is verified
    Group:
      type: object
      required: [id, link]
      properties:
        id:
          type: string
          description: Facebook id of the group the event was created in
        name:
          type: string
          description: Name of the group
        link:
          type: string
          format: uri
          description: URL of the group on Facebook
    Category:
      type: object
      required: [name]
      properties:
        id:
          type: string
          description: Facebook id of the category
        name:
          type: string
          description: Name of the category as Facebook shows it
    Tickets:
      type: object
      properties:
        link:
          type: string
          format: uri
          description: Link where tickets are sold
        seller:
          type: string
          description: Ticket seller Facebook names, such as Ticketmaster or Eventbrite
        price:
          type: string
          description: Price or price range as Facebook shows it, such as Free or $30.44 - $46.93
    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
    Occurrence:
      type: object
      required: [id, link]
      properties:
        id:
          type: string
          description: Numeric id of the occurrence
        link:
          type: string
          format: uri
          description: URL of the occurrence on Facebook
        iso_date:
          type: string
          format: date-time
          description: Time the occurrence starts, in UTC
        end_iso_date:
          type: string
          format: date-time
          description: Time the occurrence ends, in UTC
        is_past:
          type: boolean
          description: Whether the occurrence is over
    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 event
        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
        event_id:
          type: string
          description: Event id the event was requested with
        url:
          type: string
          description: Event link the event 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
