openapi: 3.0.0
info:
  title: Facebook Events API
  description: >-
    Explore public events by place ID. A place that is unknown or has no public events in the requested period returns
    a billed error. A refused page token also returns a billed error.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Facebook Events
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Search engine identifier
        schema:
          type: string
          enum:
          - facebook_events
          default: facebook_events
      - name: location_id
        in: query
        required: false
        schema:
          type: string
          pattern: "^[1-9][0-9]{0,18}$"
          maxLength: 19
        description: >-
          Place ID from facebook_location_search. Required unless next_page_token is provided. Maximum value is
          9223372036854775807.
      - name: time_period
        in: query
        required: false
        schema:
          type: string
          enum:
          - today
          - tomorrow
          - this_week
          - this_weekend
          - next_week
        description: Local calendar period. When omitted, Facebook browses the next 90 days.
      - name: next_page_token
        in: query
        required: false
        schema:
          type: string
          maxLength: 4096
        description: >-
          Token from pagination.next_page_token, bound to the location and time_period. Sparse pages may carry a token
          even when there are no events on that page. An empty final continuation returns the location and an empty
          events array without pagination. Events can repeat across pages. Use events[].id to remove duplicates.
      responses:
        '200':
          description: >-
            Explore public events by place ID. A place that is unknown or has no public events in the requested
            period returns a billed error. A refused page token also returns a billed error.
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/SearchResponse"
        '400':
          description: Invalid request parameters. 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:
    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
          nullable: true
          description: Public page for this Facebook surface.
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    ErrorResponse:
      type: object
      required:
      - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
    SearchParameters:
      type: object
      properties:
        location_id:
          type: string
          description: >-
            Place ID from facebook_location_search. Required unless next_page_token is provided. Maximum value is
            9223372036854775807.
          pattern: "^[1-9][0-9]{0,18}$"
          maxLength: 19
        time_period:
          type: string
          description: Local calendar period. When omitted, Facebook browses the next 90 days.
          enum:
          - today
          - tomorrow
          - this_week
          - this_weekend
          - next_week
        next_page_token:
          type: string
          description: >-
            Token from pagination.next_page_token, bound to the location and time_period. Sparse pages may carry a token
            even when there are no events on that page. An empty final continuation returns the location and an empty
            events array without pagination. Events can repeat across pages. Use events[].id to remove duplicates.
          maxLength: 4096
        engine:
          type: string
          description: Search engine identifier.
          enum:
          - facebook_events
        zero_retention:
          type: boolean
          description: Whether Zero Data Retention is enabled.
      required:
      - engine
    Location:
      type: object
      properties:
        id:
          type: string
          description: Positive numeric Facebook place ID. Maximum value is 9223372036854775807.
          pattern: "^[1-9][0-9]{0,18}$"
          maxLength: 19
        name:
          type: string
          description: Display name of the place
      required:
      - id
    Venue:
      type: object
      properties:
        id:
          type: string
          description: Facebook Page ID of the venue.
        name:
          type: string
          description: Venue name.
        street_address:
          type: string
          description: Street address of the venue.
    Event:
      type: object
      properties:
        position:
          type: integer
          description: One-based position in this page.
        id:
          type: string
          description: Facebook event ID.
        title:
          type: string
          description: Event title.
        link:
          type: string
          description: Public Facebook event link.
        date:
          type: string
          description: Local date and time as displayed by Facebook.
        iso_date:
          type: string
          description: 'Time the event or occurrence starts, in UTC, or the first start of a series whose date ends in "and N more".'
          format: date-time
        end_iso_date:
          type: string
          format: date-time
          description: End time in UTC.
        description:
          type: string
          description: Public event description.
        venue:
          "$ref": "#/components/schemas/Venue"
        is_past:
          type: boolean
          description: Whether the event has ended.
        is_canceled:
          type: boolean
          description: Whether Facebook says the event was canceled.
        is_happening_now:
          type: boolean
          description: Whether the event is happening now.
        is_online:
          type: boolean
          description: Whether the event is marked online in its own listing.
        interested:
          type: integer
          minimum: 0
          description: Number of people interested, rounded above 1,000 as Facebook shows it (22K is 22000).
        going:
          type: integer
          minimum: 0
          description: Number of people going, or who went to a past event, rounded above 1,000 as Facebook shows it.
        price:
          type: string
          description: Displayed ticket price or price range.
        thumbnail:
          type: string
          description: Event cover image URL.
        parent_event_id:
          type: string
          description: Parent event ID for recurring events.
        online_type:
          type: string
          description: Online event format.
        online_link:
          type: string
          description: External event link.
      required:
      - position
      - id
      - title
    SearchResponse:
      type: object
      properties:
        search_metadata:
          "$ref": "#/components/schemas/SearchMetadata"
        search_parameters:
          "$ref": "#/components/schemas/SearchParameters"
        error:
          type: string
          description: Facebook's verdict on the request, such as an unknown place or no matching results.
        location:
          "$ref": "#/components/schemas/Location"
        events:
          type: array
          items:
            "$ref": "#/components/schemas/Event"
        pagination:
          type: object
          properties:
            next_page_token:
              type: string
              description: Token for the next page.
          required:
          - next_page_token
      required:
      - search_metadata
      - search_parameters
