openapi: 3.0.0
info:
  title: Polymarket Event API
  description: |
    The Polymarket Event API returns one Polymarket prediction market event, with its rules, dates, volume, liquidity, tags and series, and its markets. Each market lists its outcomes with their current prices, which Polymarket documents as implied probabilities, plus its order book quotes and resolution state.

    Pass exactly one of `event_id`, `slug` or `url`. The `event_id` and `slug` of an event in a Polymarket Events API response can be passed as they are.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Polymarket Event
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Engine to use for the search
          schema:
            type: string
            enum: ["polymarket_event"]
            default: "polymarket_event"
        - name: event_id
          in: query
          required: false
          description: Polymarket event ID from 1 to 2147483647, such as 1353337. Pass one of event_id, slug or url.
          schema:
            type: string
            pattern: '^[0-9]{1,10}$'
        - name: slug
          in: query
          required: false
          description: Polymarket event slug, the part after /event/ in the event page URL, such as next-ceo-of-nvidia. Pass one of event_id, slug or url.
          schema:
            type: string
            pattern: '^[A-Za-z0-9_]+(-[A-Za-z0-9_]+)*$'
            maxLength: 255
        - name: url
          in: query
          required: false
          description: Polymarket event page URL, such as https://polymarket.com/event/next-ceo-of-nvidia. Pass one of event_id, slug or url.
          schema:
            type: string
            maxLength: 2048
        - name: hl
          in: query
          required: false
          description: Language of the event title, market questions and outcome names. Rules text stays in English.
          schema:
            type: string
            enum: ["en", "es", "fr", "de", "pt", "it", "ja", "ko", "zh", "ru", "tr", "hi"]
            default: "en"
        - name: zero_retention
          in: query
          required: false
          description: Set to true to disable logging and persistent storage for this request. Enterprise plans only.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as invalid values.
          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'
        '403':
          description: Account cannot use the requested feature.
          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. We could not retrieve results in 90 seconds.
          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
      required: [search_metadata, search_parameters]
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        event:
          $ref: '#/components/schemas/Event'
        markets:
          type: array
          description: The markets of the event
          items:
            $ref: '#/components/schemas/Market'
        error:
          type: string
          description: Message explaining why the response has no event, such as Polymarket event not found.
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        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: Polymarket page of the event
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Engine used for the search
        event_id:
          type: string
          description: Event ID requested
        slug:
          type: string
          description: Event slug requested
        url:
          type: string
          description: Event page URL requested
        hl:
          type: string
          description: Language requested
    Event:
      type: object
      required: [event_id, slug, title, link, tags]
      properties:
        event_id:
          type: string
          description: Polymarket event ID
        slug:
          type: string
          description: Polymarket event slug
        title:
          type: string
          description: Title of the event
        link:
          type: string
          description: Polymarket page of the event
        image:
          type: string
          description: Image of the event
        tags:
          type: array
          description: Tags Polymarket files the event under
          items:
            $ref: '#/components/schemas/Tag'
        start_date:
          type: string
          format: date-time
          description: Time the event opened, in UTC
        end_date:
          type: string
          format: date-time
          description: Time the event is scheduled to end, in UTC
        closed_date:
          type: string
          format: date-time
          description: Time the event closed, in UTC
        is_closed:
          type: boolean
          description: Whether the event has closed
        volume:
          type: number
          description: All-time trading volume in USD
        volume_24h:
          type: number
          description: Trading volume over the last 24 hours in USD
        liquidity:
          type: number
          description: Liquidity in USD
        open_interest:
          type: number
          description: Value of the open positions in USD
        comment_count:
          type: integer
          description: Number of comments on the event
        description:
          type: string
          description: Rules the event resolves by
        resolution_source:
          type: string
          description: Source the event resolves by, a URL or a name
        series:
          $ref: '#/components/schemas/Series'
        created_at:
          type: string
          format: date-time
          description: Time the event was created, in UTC
        is_neg_risk:
          type: boolean
          description: Whether Polymarket treats the markets of the event as mutually exclusive
    Series:
      type: object
      description: Recurring series the event belongs to
      required: [series_id]
      properties:
        series_id:
          type: string
          description: Polymarket series ID
        slug:
          type: string
          description: Polymarket series slug
        title:
          type: string
          description: Title of the series
        recurrence:
          type: string
          description: How often the series recurs, such as daily or monthly
    Tag:
      type: object
      required: [slug]
      properties:
        name:
          type: string
          description: Name of the tag
        slug:
          type: string
          description: Slug of the tag
    Market:
      type: object
      required: [market_id, outcomes]
      properties:
        market_id:
          type: string
          description: Polymarket market ID
        question:
          type: string
          description: Question the market resolves
        slug:
          type: string
          description: Polymarket market slug
        name:
          type: string
          description: Short name of the market within its event, such as a candidate or a price level
        condition_id:
          type: string
          description: Polymarket condition ID of the market
        description:
          type: string
          description: Rules the market resolves by
        outcomes:
          type: array
          description: The outcomes of the market
          items:
            $ref: '#/components/schemas/Outcome'
        best_bid:
          type: number
          description: Highest bid for the first outcome in USD
        best_ask:
          type: number
          description: Lowest ask for the first outcome in USD
        last_trade_price:
          type: number
          description: Price of the last trade of the first outcome in USD
        price_change_24h:
          type: number
          description: Change of the first outcome's price over the last 24 hours in USD
        volume:
          type: number
          description: All-time trading volume in USD
        liquidity:
          type: number
          description: Liquidity in USD
        volume_24h:
          type: number
          description: Trading volume over the last 24 hours in USD
        spread:
          type: number
          description: Gap between the best ask and the best bid of the first outcome in USD
        tick_size:
          type: number
          description: Smallest price step an order can take in USD
        min_order_size:
          type: number
          description: Smallest number of shares an order can take
        end_date:
          type: string
          format: date-time
          description: Time the market is scheduled to end, in UTC
        closed_date:
          type: string
          format: date-time
          description: Time the market closed, in UTC
        is_closed:
          type: boolean
          description: Whether the market has closed
        is_accepting_orders:
          type: boolean
          description: Whether the market takes new orders
        resolution_status:
          type: string
          description: Status of the market's resolution, such as proposed, disputed or resolved
        winning_outcome:
          type: string
          description: Name of the outcome a closed market priced at 1
    Outcome:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: Name of the outcome, such as Yes, No or a team
        price:
          type: number
          description: Price of one share in USD, from 0 to 1, which Polymarket documents as the outcome's implied probability
        token_id:
          type: string
          description: Polymarket token ID of the outcome
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
