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

# List Trade Aggregations

> This endpoint displays trade data based on filters set in the arguments.

This is done by dividing a given time range into segments and aggregating statistics, for a given asset pair (base, counter) over each of these segments.

The duration of the segments is specified with the `resolution` parameter. The start and end of the time range are given by `startTime` and `endTime` respectively, which are both rounded to the nearest multiple of `resolution` since epoch.

The individual segments are also aligned with multiples of `resolution` since epoch. If you want to change this alignment, the segments can be `offset` by specifying the offset parameter.


**Note:** This method has a request limit of 10 requests per second or a max of 5 requests in-flight at any one time.

This method will use `40` [Compute Units](/nodeapi/about/billing).


## OpenAPI

````yaml nodeapi/openapi/bundled-stellar-horizon-vc-urls.json GET /trade_aggregations
openapi: 3.1.0
info:
  title: Horizon
  version: 0.0.1
  summary: >-
    Horizon provides an HTTP API to data in the Stellar network. It ingests and
    re-serves the data produced by the Stellar network in a form that is easier
    to consume by the average application relative to the performance-oriented
    data representations used by Stellar Core. This API serves the bridge
    between apps and Stellar Core. Projects like wallets, decentralized
    exchanges, and asset issuers use Horizon to submit transactions, query an
    account balance, or stream events like transactions to an account.
servers:
  - url: https://{network}.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>
    variables:
      network:
        default: mainnet
        enum:
          - mainnet
          - testnet
          - archive
    description: Validation Cloud Stellar Horizon RPC
security: []
tags:
  - name: Accounts
    description: >-
      Users interact with the Stellar network through accounts. Everything else
      in the ledger—assets, offers, trustlines, etc. are owned by accounts, and
      accounts must authorize all changes to the ledger through signed
      transactions.
  - name: Assets
    description: >-
      Assets are representations of value issued on the Stellar network. An
      asset consists of a type, code, and issuer.
  - name: Claimable Balances
    description: >-
      A Claimable Balance represents the transfer of ownership of some amount of
      an asset. Claimable balances provide a mechanism for setting up a payment
      which can be claimed in the future. This allows you to make payments to
      accounts which are currently not able to accept them.
  - name: Effects
    description: >-
      Effects represent specific changes that occur in the ledger as a result of
      successful operations, but are not necessarily directly reflected in the
      ledger or history, as transactions and operations are.
  - name: Fee Stats
    description: >-
      Fee stats are used to predict what fee to set for a transaction before
      submitting it to the network.
  - name: Liquidity Pools
    description: >-
      Liquidity Pools provide a simple, non-interactive way to trade large
      amounts of capital and enable high volumes of trading.
  - name: Ledgers
    description: >-
      Each ledger stores the state of the network at a point in time and
      contains all the changes - transactions, operations, effects, etc. - to
      that state.
  - name: Offers
    description: >-
      Offers are statements about how much of an asset an account wants to buy
      or sell.
  - name: Operations
    description: >-
      Operations are objects that represent a desired change to the ledger:
      payments, offers to exchange currency, changes made to account options,
      etc. Operations are submitted to the Stellar network grouped in a
      Transaction.
  - name: Order Books
    description: An order book is a collections of offers for a specific pair of assets.
  - name: Paths
    description: >-
      Paths provide information about potential path payments. A path can be
      used to populate the necessary fields for a path payment operation.
  - name: Payments
    description: >-
      Payments are objects that represent balance transfer from one address to
      another. Payments are submitted to the Stellar network grouped in a
      Transaction.
  - name: Trade Aggregations
    description: >-
      A trade aggregation represents aggregated statistics on an asset pair
      (base and counter) for a specific time period. Trade aggregations are
      useful to developers of trading clients and provide historical trade data.
  - name: Trades
    description: >-
      When an offer is fully or partially fulfilled, a trade happens. Trades can
      also be caused by successful path payments, because path payments involve
      fulfilling offers. A trade occurs between two parties—base and counter.
      Which is which is either arbitrary or determined by the calling query.
  - name: Transactions
    description: >-
      Transactions are commands that modify the ledger state and consist of one
      or more operations.
paths:
  /trade_aggregations:
    get:
      tags:
        - Trade Aggregations
      summary: List Trade Aggregations
      description: >
        This endpoint displays trade data based on filters set in the arguments.


        This is done by dividing a given time range into segments and
        aggregating statistics, for a given asset pair (base, counter) over each
        of these segments.


        The duration of the segments is specified with the `resolution`
        parameter. The start and end of the time range are given by `startTime`
        and `endTime` respectively, which are both rounded to the nearest
        multiple of `resolution` since epoch.


        The individual segments are also aligned with multiples of `resolution`
        since epoch. If you want to change this alignment, the segments can be
        `offset` by specifying the offset parameter.
      operationId: ListTradeAggregations
      parameters:
        - $ref: '#/components/parameters/StartTimeParam'
        - $ref: '#/components/parameters/EndTimeParam'
        - $ref: '#/components/parameters/ResolutionParam'
        - $ref: '#/components/parameters/OffsetParam'
        - $ref: '#/components/parameters/BaseAssetTypeRequiredParam'
        - $ref: '#/components/parameters/BaseAssetIssuerParam'
        - $ref: '#/components/parameters/BaseAssetCodeParam'
        - $ref: '#/components/parameters/CounterAssetTypeRequiredParam'
        - $ref: '#/components/parameters/CounterAssetIssuerParam'
        - $ref: '#/components/parameters/CounterAssetCodeParam'
        - $ref: '#/components/parameters/OrderParam'
        - $ref: '#/components/parameters/LimitParam'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradeAggregation'
              examples:
                ListTradeAggregations:
                  $ref: '#/components/examples/ListTradeAggregations'
      x-codeSamples:
        - lang: Shell
          source: >
            curl https://horizon.stellar.org/trade_aggregations?\

            base_asset_type=native&\

            counter_asset_code=EURT&\

            counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&\

            counter_asset_type=credit_alphanum4&\

            resolution=3600000&\

            start_time=1582156800000&\

            end_time=1582178400000
        - lang: JavaScript
          label: '@stellar/stellar-sdk'
          source: |
            var StellarSdk = require("@stellar/stellar-sdk");
            var server = new StellarSdk.Horizon.Server(
              "https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>/",
            );

            var base = new StellarSdk.Asset.native();
            var counter = new StellarSdk.Asset(
              "EURT",
              "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S",
            );
            var startTime = 1582156800000;
            var endTime = 1582178400000;
            var resolution = 3600000;
            var offset = 0;

            server
              .tradeAggregation(base, counter, startTime, endTime, resolution, offset)
              .call()
              .then(function (resp) {
                console.log(resp);
              })
              .catch(function (err) {
                console.error(err);
              });
components:
  parameters:
    StartTimeParam:
      name: start_time
      in: query
      required: false
      description: The lower time boundary represented as milliseconds since epoch.
      schema:
        type: integer
        format: long
    EndTimeParam:
      name: end_time
      in: query
      required: false
      description: The upper time boundary represented as milliseconds since epoch.
      schema:
        type: integer
        format: long
    ResolutionParam:
      name: resolution
      in: query
      required: false
      description: >-
        The segment duration represented as milliseconds. Supported values are 1
        minute (60000), 5 minutes (300000), 15 minutes (900000), 1 hour
        (3600000), 1 day (86400000) and 1 week (604800000).
      schema:
        type: integer
        format: long
        oneOf:
          - const: 60000
            description: 1 minute
          - const: 300000
            description: 5 minutes
          - const: 900000
            description: 15 minutes
          - const: 3600000
            description: 1 hour
          - const: 86400000
            description: 1 day
          - const: 604800000
            description: 1 week
    OffsetParam:
      name: offset
      in: query
      required: false
      description: >-
        Segments can be offset using this parameter. Expressed in milliseconds.
        Can only be used if the resolution is greater than 1 hour. Value must be
        in whole hours, less than the provided resolution, and less than 24
        hours.
      schema:
        type: number
        format: long
    BaseAssetTypeRequiredParam:
      name: base_asset_type
      in: query
      required: true
      description: >-
        The type for the base asset. Either `native`, `credit_alphanum4`, or
        `credit_alphanum12`.
      schema:
        type: string
        enum:
          - native
          - credit_alphanum4
          - credit_alphanum12
    BaseAssetIssuerParam:
      name: base_asset_issuer
      in: query
      required: false
      description: >-
        The Stellar address of the base asset’s issuer. Required if the
        `base_asset_type` is not `native`.
      schema:
        type: string
        example: GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX
    BaseAssetCodeParam:
      name: base_asset_code
      in: query
      required: false
      description: >-
        The code for the base asset. Required if the `base_asset_type` is not
        `native`.
      schema:
        type: string
        example: USD
    CounterAssetTypeRequiredParam:
      name: counter_asset_type
      in: query
      required: true
      description: >-
        The type for the counter asset. Either `native`, `credit_alphanum4`, or
        `credit_alphanum12`.
      schema:
        type: string
        enum:
          - native
          - credit_alphanum4
          - credit_alphanum12
    CounterAssetIssuerParam:
      name: counter_asset_issuer
      in: query
      required: false
      description: >-
        The Stellar address of the counter asset’s issuer. Required if the
        `counter_asset_type` is not `native`.
      schema:
        type: string
        example: GDUKMGUGDZQK6YHYA5Z6AY2G4XDSZPSZ3SW5UN3ARVMO6QSRDWP5YLEX
    CounterAssetCodeParam:
      name: counter_asset_code
      in: query
      required: false
      description: >-
        The code for the counter asset. Required if the `counter_asset_type` is
        not `native`.
      schema:
        type: string
        example: USD
    OrderParam:
      name: order
      in: query
      required: false
      description: >-
        A designation of the order in which records should appear. Options
        include `asc` (ascending) or `desc` (descending). If this argument isn’t
        set, it defaults to `asc`.
      schema:
        type: string
        enum:
          - asc
          - desc
    LimitParam:
      name: limit
      in: query
      required: false
      description: >-
        The maximum number of records returned. The limit can range from 1 to
        200 - an upper limit that is hardcoded in Horizon for performance
        reasons. If this argument isn’t designated, it defaults to 10.
      schema:
        type: integer
        example: 10
  schemas:
    TradeAggregation:
      type: object
      properties:
        _embedded:
          type: object
          properties:
            records:
              type: array
              items:
                type: object
                properties:
                  timestamp:
                    type: string
                  trade_count:
                    type: string
                  base_volume:
                    type: string
                  counter_volume:
                    type: string
                  avg:
                    type: string
                  high:
                    type: string
                  high_r:
                    $ref: '#/components/schemas/tradePrice'
                  low:
                    type: string
                  low_r:
                    $ref: '#/components/schemas/tradePrice'
                  open:
                    type: string
                  open_r:
                    $ref: '#/components/schemas/tradePrice'
                  close:
                    type: string
                  close_r:
                    $ref: '#/components/schemas/tradePrice'
    tradePrice:
      type: object
      properties:
        'n':
          type: string
        d:
          type: string
  examples:
    ListTradeAggregations:
      value:
        _links:
          self:
            href: >-
              https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&resolution=3600000&start_time=1582156800000&end_time=1582178400001
          next:
            href: >-
              https://mainnet.stellar.validationcloud.io/v1/<YOUR_API_KEY_HERE>//trade_aggregations?base_asset_type=native&counter_asset_code=EURT&counter_asset_issuer=GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S&counter_asset_type=credit_alphanum4&end_time=1582178400001&resolution=3600000&start_time=1582171200000
          prev:
            href: ''
        _embedded:
          records:
            - timestamp: 1582164000000
              trade_count: 3
              base_volume: '399.3873200'
              counter_volume: '25.5368082'
              avg: '0.0639400'
              high: '0.0652169'
              high_r:
                'N': 652169
                D: 10000000
              low: '0.0638338'
              low_r:
                'N': 8107550
                D: 127010393
              open: '0.0652169'
              open_r:
                'N': 652169
                D: 10000000
              close: '0.0638338'
              close_r:
                'N': 8107550
                D: 127010393
            - timestamp: 1582167600000
              trade_count: 1
              base_volume: '149.8415320'
              counter_volume: '9.7149804'
              avg: '0.0648350'
              high: '0.0648350'
              high_r:
                'N': 5000000
                D: 77118803
              low: '0.0648350'
              low_r:
                'N': 5000000
                D: 77118803
              open: '0.0648350'
              open_r:
                'N': 5000000
                D: 77118803
              close: '0.0648350'
              close_r:
                'N': 5000000
                D: 77118803

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.