> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ainvest.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Candles

> Use this endpoint to get prices as OHLCV (open-high-low-closed-volume) data for specified period, aggregation interval and trading session

<img src="https://mintcdn.com/ainvest-8e114140/DGzrPnVwd1HT0tfj/images/mcp-claude-candles.png?fit=max&auto=format&n=DGzrPnVwd1HT0tfj&q=85&s=f61f65b622e73ce3b772b046dcdc9190" width="1394" height="769" data-path="images/mcp-claude-candles.png" />


## OpenAPI

````yaml reference/marketdata/marketdata.yaml GET /marketdata/candles
openapi: 3.1.0
info:
  title: Get time series data
  description: >-
    Get time series data, including candles and indicators for US stocks and
    ETFs
  version: 1.0.0
servers:
  - url: https://openapi.ainvest.com/open
    description: Production environment
security:
  - bearerAuth: []
tags:
  - name: Marketdata
    description: >-
      Provides access to time series data, including candles and indicators for
      US stocks and ETFs
    externalDocs:
      url: https://docs.ainvest.com/marketdata/candles
paths:
  /marketdata/candles:
    get:
      tags:
        - Marketdata
      summary: Candles
      description: >-
        Use this endpoint to get prices as OHLCV (open-high-low-closed-volume)
        data for specified period, aggregation interval and trading session
      operationId: getCandles
      parameters:
        - name: ticker
          in: query
          required: true
          description: US stock market ticker symbol, e.g. AAPL, TSLA, etc.
          schema:
            type: string
        - name: interval
          in: query
          required: true
          description: Aggregation interval for the requested data
          schema:
            type: string
            enum:
              - min
              - day
              - week
              - month
              - year
        - name: step
          in: query
          required: true
          description: >-
            Aggregation step for each candle. For example, `interval=day&step=1`
            for daily candles, `interval=min&step=15` for 15-minute candles.
          schema:
            type: integer
        - name: from
          in: query
          required: true
          description: Start of the requested period, unix timestamp with milliseconds
          schema:
            type: integer
        - name: to
          in: query
          required: false
          description: >-
            End of the requested period, unix timestamp with milliseconds.
            Default value of `0` represents the latest available data.
          schema:
            type: integer
            default: 0
        - name: session
          in: query
          required: false
          description: >-
            Trading session, where `pre_market` is pre-market session,
            `intraday` is for regular trading session, and `post_market` is
            post-market session. Default value is `intraday`.
          schema:
            type: string
            default: intraday
            enum:
              - pre_market
              - intraday
              - post_market
        - name: adjustment
          in: query
          required: false
          description: >
            Adjust the historical prices for corporate actions, can be one of
            the following values:

            | value | description |

            |----------------|----------------|

            | `actual` | Return prices as is, no adjustment (default value) |

            | `backward_3` | adjust backward for splits, bonus shares, spin
            offs, dividends |

            | `backward_2` | adjust backward for splits, bonus shares, spin offs
            |

            | `backward_1` | adjust backward for splits, bonus shares |

            | `backward` | adjust backward for splits only |

            | `forward_3` | adjust forward for splits, bonus shares, spin offs,
            dividends |

            | `forward_2` | adjust forward for splits, bonus shares, spin offs |

            | `forward_1` | adjust forward for splits, bonus shares |

            | `forward` | adjust forward for splits only |
          schema:
            type: string
            default: actual
            enum:
              - actual
              - backward_3
              - backward_2
              - backward_1
              - backward
              - forward_3
              - forward_2
              - forward_1
              - forward
      responses:
        '200':
          description: Successful response in standard envelope.
          content:
            application/json:
              schema:
                $schema: http://json-schema.org/draft-04/schema#
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      data:
                        type: array
                        description: >-
                          A list of candles, in time order, from oldest to
                          newest
                        items:
                          $ref: '#/components/schemas/Candle'
                  status_code:
                    type: number
                    description: Status code, `0` for success
                  status_msg:
                    type: string
                    description: Status message, `success` for success
        '400':
          description: >-
            Validation error, i.e. requested stock is not found or parameter is
            not specified
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status_code: 4012
                status_msg: Invalid param
components:
  schemas:
    Candle:
      type: object
      properties:
        t:
          type: number
          description: Unix timestamp with milliseconds at the end of the interval
        o:
          type: number
          description: The price at the opening
        h:
          type: number
          description: The high price
        l:
          type: number
          description: The low price
        c:
          type: number
          description: The price at the closing
        v:
          type: number
          description: The volume, number of trades during the period
        a:
          type: number
          description: The volume of trades, in dollars
    Error:
      type: object
      properties:
        status_code:
          type: integer
          description: Business status code
        status_msg:
          type: string
          description: Error message
      required:
        - status_code
        - status_msg
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your key. [Get the key
        here](https://www.ainvest.com/business/developer-manage/)

````