openapi: 3.0.0
info:
  title: Facebook Location Search API
  description: >-
    Find public Facebook place IDs and coordinates by name or postal code. Pass locations[].id to facebook_events
    as location_id. Postal areas may have no events. Search by city name for nearby events. A query with no matches returns a billed error.
  version: 1.0.0
servers:
- url: https://www.searchapi.io/api/v1
paths:
  "/search":
    get:
      summary: Facebook Location Search
      security:
      - ApiKeyAuth: []
      - ApiKeyQuery: []
      parameters:
      - name: engine
        in: query
        required: true
        description: Search engine identifier
        schema:
          type: string
          enum:
          - facebook_location_search
          default: facebook_location_search
      - name: q
        in: query
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 200
        description: Place name or postal code, such as Austin, Texas.
      responses:
        '200':
          description: >-
            Find public Facebook place IDs and coordinates by name or postal code. Pass locations[].id to facebook_events
            as location_id. Postal areas may have no events. Search by city name for nearby events. A query with no matches 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:
        q:
          type: string
          description: Place name or postal code, such as Austin, Texas.
          minLength: 1
          maxLength: 200
        engine:
          type: string
          description: Search engine identifier.
          enum:
          - facebook_location_search
        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
        description:
          type: string
          description: Facebook's place subtitle, such as City.
        city:
          type: string
          description: City reported for the place.
        postal_code:
          type: string
          description: Postal code of the place.
        latitude:
          type: number
          description: Latitude in degrees.
        longitude:
          type: number
          description: Longitude in degrees.
      required:
      - id
      - name
      - latitude
      - longitude
    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 no matching locations.
        locations:
          type: array
          items:
            "$ref": "#/components/schemas/Location"
      required:
      - search_metadata
      - search_parameters
