swagger: "2.0"
schemes:
  - https
host: api.polygon.io
info:
  contact:
    x-twitter: polygon_io
  description: The future of fintech.
  title: Polygon
  version: 1.0.0
  x-apisguru-categories:
    - financial
  x-logo:
    url: https://twitter.com/polygon_io/profile_image?size=original
  x-origin:
    - format: swagger
      url: https://polygon.io/docs/swagger.json
      version: "2.0"
  x-providerName: polygon.io
produces:
  - application/json
securityDefinitions:
  apiKey:
    in: query
    name: apiKey
    type: apiKey
security:
  - apiKey: []
paths:
  /v1/companies:
    get:
      description: |
        Get a list of the traded companies that polygon.io streams. Company includes some details about the company which we hope to add more to soon.
      parameters:
        - description: Which field to sort by. For desc place a `-` in front of the field name. eg `?sort=-marketcap`
          in: query
          name: sort
          required: false
          type: string
        - description: How many items to be on each page during pagination
          in: query
          name: perpage
          required: false
          type: number
        - default: 1
          description: Which page of results to return
          in: query
          name: page
          required: false
          type: number
      responses:
        "200":
          description: An array of companies
          schema:
            items:
              $ref: "#/definitions/Company"
            type: array
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Available Companies
      tags:
        - Stocks
  /v1/currencies:
    get:
      description: |
        Get a list of the currencies that polygon.io streams.
      responses:
        "200":
          description: An array of currencies
          schema:
            items:
              type: string
            type: array
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Available Currencies
      tags:
        - Currencies
  "/v1/historic/agg/{size}/{symbol}/{date}":
    get:
      description: |
        Get historic aggregations for a symbol.
      parameters:
        - description: Size of the aggregation. `second` or `minute`
          enum:
            - second
            - minute
          in: path
          name: size
          required: true
          type: string
        - description: Symbol of the company to retrieve
          in: path
          name: symbol
          required: true
          type: string
        - description: Date/Day of the historic ticks to retreive
          format: date
          in: path
          name: date
          required: true
          type: string
        - description: Timestamp offset, used for pagination
          in: query
          name: offset
          required: false
          type: integer
        - default: 100
          description: "Limit the size of response, max: 10000"
          in: query
          name: limit
          required: false
          type: integer
      responses:
        "200":
          description: An array of aggregates
          schema:
            properties:
              day:
                description: Date that was evaluated from the request
                format: date
                type: string
              msLatency:
                description: Milliseconds of latency for the query results
                type: integer
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
              ticks:
                items:
                  $ref: "#/definitions/Aggregate"
                type: array
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Historic Aggregates
      tags:
        - Stocks
  "/v1/historic/forex/{from}/{to}/{date}":
    get:
      description: |
        Get historic ticks for a currency pair. Example for **USD/JPY** the from would be **USD** and to would be **JPY**. The date formatted like **2017-6-22**
      parameters:
        - description: From Symbol of the currency pair
          in: path
          name: from
          required: true
          type: string
        - description: To Symbol of the currency pair
          in: path
          name: to
          required: true
          type: string
        - description: Date/Day of the historic ticks to retreive
          format: date
          in: path
          name: date
          required: true
          type: string
        - description: Timestamp offset, used for pagination
          in: query
          name: offset
          required: false
          type: integer
        - default: 100
          description: "Limit the size of response, max: 10000"
          in: query
          name: limit
          required: false
          type: integer
      responses:
        "200":
          description: An array of forex ticks
          schema:
            properties:
              day:
                description: Date that was evaluated from the request
                format: date
                type: string
              msLatency:
                description: Milliseconds of latency for the query results
                type: integer
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
              ticks:
                items:
                  $ref: "#/definitions/Forex"
                type: array
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Historic Forex Ticks
      tags:
        - Currencies
  "/v1/historic/quotes/{symbol}/{date}":
    get:
      description: |
        Get historic quotes for a symbol.
      parameters:
        - description: Symbol of the company to retrieve
          in: path
          name: symbol
          required: true
          type: string
        - description: Date/Day of the historic ticks to retreive
          format: date
          in: path
          name: date
          required: true
          type: string
        - description: Timestamp offset, used for pagination
          in: query
          name: offset
          required: false
          type: integer
        - default: 100
          description: "Limit the size of response, max: 10000"
          in: query
          name: limit
          required: false
          type: integer
      responses:
        "200":
          description: An array of quotes
          schema:
            properties:
              day:
                description: Date that was evaluated from the request
                format: date
                type: string
              msLatency:
                description: Milliseconds of latency for the query results
                type: integer
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
              ticks:
                items:
                  $ref: "#/definitions/Quote"
                type: array
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Historic Quotes
      tags:
        - Stocks
  "/v1/historic/trades/{symbol}/{date}":
    get:
      description: |
        Get historic trades for a symbol.
      parameters:
        - description: Symbol of the company to retrieve
          in: path
          name: symbol
          required: true
          type: string
        - description: Date/Day of the historic ticks to retreive
          format: date
          in: path
          name: date
          required: true
          type: string
        - description: Timestamp offset, used for pagination
          in: query
          name: offset
          required: false
          type: integer
        - default: 100
          description: "Limit the size of response, max: 10000"
          in: query
          name: limit
          required: false
          type: integer
      responses:
        "200":
          description: An array of trades
          schema:
            properties:
              day:
                description: Date that was evaluated from the request
                format: date
                type: string
              msLatency:
                description: Milliseconds of latency for the query results
                type: integer
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
              ticks:
                items:
                  $ref: "#/definitions/Trade"
                type: array
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Historic Trades
      tags:
        - Stocks
  "/v1/last/currencies/{from}/{to}":
    get:
      description: |
        Get Last Trade Tick for a Currency Pair.
      parameters:
        - description: From Symbol of the pair
          in: path
          name: from
          required: true
          type: string
        - description: To Symbol of the pair
          in: path
          name: to
          required: true
          type: string
      responses:
        "200":
          description: Last tick for this currency pair
          schema:
            properties:
              last:
                $ref: "#/definitions/LastForexTrade"
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol Pair that was evaluated from the request
                type: string
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Last Trade for a Currency Pair
      tags:
        - Currencies
  "/v1/last/stocks/{symbol}":
    get:
      description: |
        Get the last trade for a given stock.
      parameters:
        - description: Symbol of the stock to get
          in: path
          name: symbol
          required: true
          type: string
      responses:
        "200":
          description: Last trade for this stock
          schema:
            properties:
              last:
                $ref: "#/definitions/LastTrade"
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Last Trade for a Symbol
      tags:
        - Stocks
  "/v1/last_quote/currencies/{from}/{to}":
    get:
      description: |
        Get Last Quote Tick for a Currency Pair.
      parameters:
        - description: From Symbol of the pair
          in: path
          name: from
          required: true
          type: string
        - description: To Symbol of the pair
          in: path
          name: to
          required: true
          type: string
      responses:
        "200":
          description: Last quote tick for this currency pair
          schema:
            properties:
              last:
                $ref: "#/definitions/LastForexQuote"
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol Pair that was evaluated from the request
                type: string
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Last Quote for a Currency Pair
      tags:
        - Currencies
  "/v1/last_quote/stocks/{symbol}":
    get:
      description: |
        Get the last quote tick for a given stock.
      parameters:
        - description: Symbol of the stock to get
          in: path
          name: symbol
          required: true
          type: string
      responses:
        "200":
          description: Last quote tick for this stock
          schema:
            properties:
              last:
                $ref: "#/definitions/LastQuote"
              status:
                description: Status of this requests response
                type: string
              symbol:
                description: Symbol that was evaluated from the request
                type: string
            type: object
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Last Quote for a Symbol
      tags:
        - Stocks
definitions:
  Aggregate:
    properties:
      c:
        description: Close price
        type: integer
      h:
        description: High price
        type: integer
      k:
        description: Transactions ( 1 transaction contains X shares exchanged )
        type: integer
      l:
        description: Low price
        type: integer
      o:
        description: Open price
        type: integer
      t:
        description: Timestamp of this aggregation
        type: integer
      v:
        description: Total Volume of all trades ( total shares exchanged )
        type: integer
    type: object
  Company:
    properties:
      country:
        description: Country in which this country is based.
        type: string
      exchange:
        description: Exchange this company is traded on.
        type: string
      industry:
        description: Industry this country operated/produces in.
        type: string
      marketcap:
        description: Market cap as of the last updated timestamp.
        format: double
        type: number
      name:
        description: Name of the company.
        type: string
      sector:
        description: Sector that this company is traded in.
        type: string
      symbol:
        description: The actual exchange symbol this company is traded under.
        type: string
      updated:
        description: Last time this company record was updated.
        format: date-time
        type: string
    type: object
  Error:
    properties:
      code:
        format: int32
        type: integer
      fields:
        type: string
      message:
        type: string
    type: object
  Forex:
    properties:
      a:
        description: Ask price
        type: integer
      b:
        description: Bid price
        type: integer
      t:
        description: Timestamp of this trade
        type: integer
    type: object
  LastForexQuote:
    properties:
      askprice:
        description: Ask Price
        format: double
        type: number
      bidprice:
        description: Bid Price
        format: double
        type: number
      timestamp:
        description: Timestamp of this trade
        type: integer
    type: object
  LastForexTrade:
    properties:
      exchange:
        description: Exchange this trade happened on
        type: integer
      price:
        description: Price of the trade
        format: double
        type: number
      timestamp:
        description: Timestamp of this trade
        type: integer
    type: object
  LastQuote:
    properties:
      askexchange:
        description: Exchange the ask happened on
        type: integer
      askprice:
        description: Ask Price
        format: double
        type: number
      asksize:
        description: Ask Size
        type: integer
      bidexchange:
        description: Exchange the bid happened on
        type: integer
      bidprice:
        description: Bid Price
        format: double
        type: number
      bidsize:
        description: Bid Size
        type: integer
      cond:
        description: Condition of the quote
        type: integer
      timestamp:
        description: Timestamp of this trade
        type: integer
    type: object
  LastTrade:
    properties:
      cond1:
        description: Condition 1 of the trade
        type: integer
      cond2:
        description: Condition 2 of the trade
        type: integer
      cond3:
        description: Condition 3 of the trade
        type: integer
      cond4:
        description: Condition 4 of the trade
        type: integer
      exchange:
        description: Exchange this trade happened on
        type: integer
      price:
        description: Price of the trade
        format: double
        type: number
      size:
        description: Size of this trade
        type: integer
      timestamp:
        description: Timestamp of this trade
        type: integer
    type: object
  Quote:
    properties:
      aE:
        description: Ask Exchange
        type: string
      aP:
        description: Ask Price
        format: double
        type: number
      aS:
        description: Ask Size
        type: integer
      bE:
        description: Bid Exchange
        type: string
      bP:
        description: Bid Price
        format: double
        type: number
      bS:
        description: Bid Size
        type: integer
      c:
        description: Condition of this quote
        type: integer
      t:
        description: Timestamp of this trade
        type: integer
    type: object
  Trade:
    properties:
      c1:
        description: Condition 1 of this trade
        type: integer
      c2:
        description: Condition 2 of this trade
        type: integer
      c3:
        description: Condition 3 of this trade
        type: integer
      c4:
        description: Condition 4 of this trade
        type: integer
      e:
        description: The exchange this trade happened on
        type: string
      p:
        description: Price of this trade
        format: double
        type: number
      s:
        description: Size of the trade
        type: integer
      t:
        description: Timestamp of this trade
        type: integer
    type: object
