> ## 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.

# Trades

> Use this endpoint to get `count` trades for a specific stock `ticker`, printed immediately before the `to` timestamp. The trades are ordered by time, ascending.

<Danger>Currently only returns data for current trading day. Access to historical tick data is not implemented yet</Danger>


## OpenAPI

````yaml reference/marketdata/marketdata.yaml GET /marketdata/trades
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/trades:
    get:
      tags:
        - Marketdata
      summary: Get trades data (also known as time and sales)
      description: >-
        Use this endpoint to get `count` trades for a specific stock `ticker`,
        printed immediately before the `to` timestamp. The trades are ordered by
        time, ascending.
      operationId: getTrades
      parameters:
        - name: ticker
          in: query
          required: true
          description: US stock market ticker symbol, e.g. AAPL, TSLA, etc.
          schema:
            type: string
        - name: count
          in: query
          required: true
          description: The number of trades to return
          schema:
            type: number
        - name: to
          in: query
          required: true
          description: End of the requested period, unix timestamp with milliseconds
          schema:
            type: integer
      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 trades, in time order, from newest to oldest
                        items:
                          $ref: '#/components/schemas/Trade'
                  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:
    Trade:
      type: object
      properties:
        t:
          type: number
          description: Unix timestamp with milliseconds
        p:
          type: number
          description: Trade
        q:
          type: number
          description: Quantity
    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/)

````