Twitch Predictions API

Create and manage channel predictions

Documentation

Specifications

Other Resources

OpenAPI Specification

twitch-predictions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Twitch Drops Ads Predictions API
  description: APIs for game developers to create and manage Drops campaigns that grant in-game rewards to Twitch viewers watching streamers play their game. Drops campaigns are managed through the Twitch Developer Console and fulfilled via the Helix API entitlements endpoints.
  version: '1.0'
  contact:
    name: Twitch Developer Support
    url: https://dev.twitch.tv/support/
  termsOfService: https://www.twitch.tv/p/legal/terms-of-service/
servers:
- url: https://api.twitch.tv/helix
  description: Twitch Helix API Production
security:
- oauth2: []
tags:
- name: Predictions
  description: Create and manage channel predictions
paths:
  /predictions:
    get:
      operationId: getPredictions
      summary: Twitch Get Predictions
      description: Gets predictions for the specified broadcaster's channel.
      tags:
      - Predictions
      parameters:
      - $ref: '#/components/parameters/clientId'
      - name: broadcaster_id
        in: query
        required: true
        schema:
          type: string
      - name: id
        in: query
        schema:
          type: string
      - $ref: '#/components/parameters/first'
      - $ref: '#/components/parameters/after'
      responses:
        '200':
          description: Predictions returned successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Prediction'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
    post:
      operationId: createPrediction
      summary: Twitch Create Prediction
      description: Creates a prediction for the specified broadcaster's channel.
      tags:
      - Predictions
      parameters:
      - $ref: '#/components/parameters/clientId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PredictionInput'
      responses:
        '200':
          description: Prediction created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Prediction'
components:
  schemas:
    Prediction:
      type: object
      properties:
        id:
          type: string
        broadcaster_id:
          type: string
        broadcaster_name:
          type: string
        broadcaster_login:
          type: string
        title:
          type: string
        winning_outcome_id:
          type: string
          nullable: true
        outcomes:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              title:
                type: string
              users:
                type: integer
              channel_points:
                type: integer
              color:
                type: string
                enum:
                - BLUE
                - PINK
              top_predictors:
                type: array
                nullable: true
                items:
                  type: object
                  properties:
                    user_id:
                      type: string
                    user_name:
                      type: string
                    user_login:
                      type: string
                    channel_points_used:
                      type: integer
                    channel_points_won:
                      type: integer
        prediction_window:
          type: integer
        status:
          type: string
          enum:
          - ACTIVE
          - RESOLVED
          - CANCELED
          - LOCKED
        created_at:
          type: string
          format: date-time
        ended_at:
          type: string
          format: date-time
          nullable: true
        locked_at:
          type: string
          format: date-time
          nullable: true
    PredictionInput:
      type: object
      required:
      - broadcaster_id
      - title
      - outcomes
      - prediction_window
      properties:
        broadcaster_id:
          type: string
        title:
          type: string
          maxLength: 45
        outcomes:
          type: array
          minItems: 2
          maxItems: 10
          items:
            type: object
            required:
            - title
            properties:
              title:
                type: string
                maxLength: 25
        prediction_window:
          type: integer
          minimum: 1
          maximum: 1800
    Pagination:
      type: object
      properties:
        cursor:
          type: string
          description: Cursor value for pagination
  parameters:
    after:
      name: after
      in: query
      schema:
        type: string
      description: Cursor for forward pagination
    first:
      name: first
      in: query
      schema:
        type: integer
        default: 20
        maximum: 100
      description: Maximum number of items to return
    clientId:
      name: Client-Id
      in: header
      required: true
      schema:
        type: string
      description: Your registered application's client ID
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://id.twitch.tv/oauth2/token
          scopes: {}
externalDocs:
  description: Twitch Drops Documentation
  url: https://dev.twitch.tv/docs/drops/