Polygon Aggregates API

Crypto aggregate bars.

Documentation

Specifications

Schemas & Data

Other Resources

OpenAPI Specification

polygon-aggregates-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Polygon Crypto REST Aggregates API
  version: '1.0'
  description: 'Polygon Crypto API exposes aggregated cross-exchange data for crypto

    pairs (e.g., X:BTCUSD) via `https://api.polygon.io`. This spec

    covers aggregates, daily open/close, snapshots, and level-2 books.

    Auth uses an API key via `apiKey` query parameter or

    `Authorization: Bearer`.

    '
  contact:
    name: Polygon Documentation
    url: https://polygon.io/docs/crypto
servers:
- url: https://api.polygon.io
  description: Polygon REST API
security:
- apiKeyQuery: []
- bearerAuth: []
tags:
- name: Aggregates
  description: Crypto aggregate bars.
paths:
  /v2/aggs/ticker/{cryptoTicker}/range/{multiplier}/{timespan}/{from}/{to}:
    get:
      tags:
      - Aggregates
      operationId: getCryptoAggregateBars
      summary: Get Aggregate Bars For A Crypto Pair
      description: Aggregate bars for a crypto pair (e.g., X:BTCUSD).
      parameters:
      - in: path
        name: cryptoTicker
        required: true
        schema:
          type: string
      - in: path
        name: multiplier
        required: true
        schema:
          type: integer
      - in: path
        name: timespan
        required: true
        schema:
          type: string
          enum:
          - minute
          - hour
          - day
          - week
          - month
          - quarter
          - year
      - in: path
        name: from
        required: true
        schema:
          type: string
      - in: path
        name: to
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Crypto aggregate bars response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse'
  /v2/aggs/ticker/{forexTicker}/range/{multiplier}/{timespan}/{from}/{to}:
    get:
      tags:
      - Aggregates
      operationId: getForexAggregateBars
      summary: Get Aggregate Bars For A Forex Pair
      description: Aggregate bars (OHLC) for an FX pair (e.g., C:EURUSD).
      parameters:
      - in: path
        name: forexTicker
        required: true
        schema:
          type: string
      - in: path
        name: multiplier
        required: true
        schema:
          type: integer
      - in: path
        name: timespan
        required: true
        schema:
          type: string
          enum:
          - minute
          - hour
          - day
          - week
          - month
          - quarter
          - year
      - in: path
        name: from
        required: true
        schema:
          type: string
      - in: path
        name: to
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Forex aggregate bars response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse'
  /v2/aggs/ticker/{forexTicker}/prev:
    get:
      tags:
      - Aggregates
      operationId: getForexPreviousClose
      summary: Get Previous Close For A Forex Pair
      parameters:
      - in: path
        name: forexTicker
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Forex previous close response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse'
  /v2/aggs/ticker/{indicesTicker}/range/{multiplier}/{timespan}/{from}/{to}:
    get:
      tags:
      - Aggregates
      operationId: getIndicesAggregateBars
      summary: Get Aggregate Bars For An Index
      description: Aggregate bars (OHLC) for an index ticker over a date range.
      parameters:
      - in: path
        name: indicesTicker
        required: true
        schema:
          type: string
      - in: path
        name: multiplier
        required: true
        schema:
          type: integer
      - in: path
        name: timespan
        required: true
        schema:
          type: string
          enum:
          - minute
          - hour
          - day
          - week
          - month
          - quarter
          - year
      - in: path
        name: from
        required: true
        schema:
          type: string
      - in: path
        name: to
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Indices aggregate bars response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse'
  /v2/aggs/ticker/{indicesTicker}/prev:
    get:
      tags:
      - Aggregates
      operationId: getIndicesPreviousClose
      summary: Get Previous Close For An Index
      description: Returns the previous day's open/close/high/low for an index.
      parameters:
      - in: path
        name: indicesTicker
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Indices previous close response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse'
  /v2/aggs/ticker/{optionsTicker}/range/{multiplier}/{timespan}/{from}/{to}:
    get:
      tags:
      - Aggregates
      operationId: getOptionsAggregateBars
      summary: Get Aggregate Bars For An Options Contract
      description: Aggregate bars (OHLC) for an options contract.
      parameters:
      - in: path
        name: optionsTicker
        required: true
        schema:
          type: string
      - in: path
        name: multiplier
        required: true
        schema:
          type: integer
      - in: path
        name: timespan
        required: true
        schema:
          type: string
          enum:
          - minute
          - hour
          - day
          - week
          - month
          - quarter
          - year
      - in: path
        name: from
        required: true
        schema:
          type: string
      - in: path
        name: to
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Options aggregate bars response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse_2'
  /v2/aggs/ticker/{stocksTicker}/range/{multiplier}/{timespan}/{from}/{to}:
    get:
      tags:
      - Aggregates
      operationId: getStocksAggregateBars
      summary: Get Aggregate Bars For A Stock Ticker
      description: 'Returns aggregate bars for a stock over a given date range in

        custom time window sizes (e.g., 5-minute bars between two dates).

        '
      parameters:
      - in: path
        name: stocksTicker
        required: true
        schema:
          type: string
        description: Case-sensitive stock ticker symbol (e.g., AAPL).
      - in: path
        name: multiplier
        required: true
        schema:
          type: integer
          minimum: 1
        description: Size of the timespan multiplier.
      - in: path
        name: timespan
        required: true
        schema:
          type: string
          enum:
          - second
          - minute
          - hour
          - day
          - week
          - month
          - quarter
          - year
      - in: path
        name: from
        required: true
        schema:
          type: string
        description: Start of the aggregate window (YYYY-MM-DD or millisecond timestamp).
      - in: path
        name: to
        required: true
        schema:
          type: string
        description: End of the aggregate window (YYYY-MM-DD or millisecond timestamp).
      - in: query
        name: adjusted
        schema:
          type: boolean
          default: true
      - in: query
        name: sort
        schema:
          type: string
          enum:
          - asc
          - desc
      - in: query
        name: limit
        schema:
          type: integer
          minimum: 1
          maximum: 50000
          default: 5000
      responses:
        '200':
          description: Aggregate bars response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatesResponse_3'
components:
  schemas:
    AggregatesResponse_2:
      type: object
      properties:
        ticker:
          type: string
        adjusted:
          type: boolean
        queryCount:
          type: integer
        resultsCount:
          type: integer
        status:
          type: string
        request_id:
          type: string
        results:
          type: array
          items:
            $ref: '#/components/schemas/AggregateBar'
    AggregatesResponse_3:
      type: object
      properties:
        ticker:
          type: string
        adjusted:
          type: boolean
        queryCount:
          type: integer
        resultsCount:
          type: integer
        status:
          type: string
        request_id:
          type: string
        count:
          type: integer
        next_url:
          type: string
          format: uri
        results:
          type: array
          items:
            $ref: '#/components/schemas/AggregateBar_2'
    AggregatesResponse:
      type: object
      properties:
        ticker:
          type: string
        status:
          type: string
        request_id:
          type: string
        resultsCount:
          type: integer
        results:
          type: array
          items:
            $ref: '#/components/schemas/AggregateBar'
    AggregateBar:
      type: object
      properties:
        v:
          type: number
        vw:
          type: number
        o:
          type: number
        c:
          type: number
        h:
          type: number
        l:
          type: number
        t:
          type: integer
          format: int64
        n:
          type: integer
    AggregateBar_2:
      type: object
      properties:
        T:
          type: string
          description: Ticker symbol (only present on certain endpoints).
        v:
          type: number
          description: Trading volume.
        vw:
          type: number
          description: Volume-weighted average price.
        o:
          type: number
          description: Open price.
        c:
          type: number
          description: Close price.
        h:
          type: number
          description: High price.
        l:
          type: number
          description: Low price.
        t:
          type: integer
          format: int64
          description: Unix millisecond timestamp.
        n:
          type: integer
          description: Number of transactions.
  securitySchemes:
    apiKeyQuery:
      type: apiKey
      in: query
      name: apiKey
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key