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

# Get trades in a time window

> A perp market's fills between two timestamps, newest first, optionally only those worth at
least `min_notional_usd`. The window can be at most 31 days. Both legs of a fill are returned.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v1/trades/window
openapi: 3.1.0
info:
  title: Decibel Trading API
  description: >-
    RESTful API for Decibel. Provides read-only endpoints for market data,
    trading operations, positions, and analytics.
  contact:
    name: Decibel Team
    url: https://decibel.trade/
  license:
    name: ''
  version: 1.0.0
servers:
  - url: https://api.mainnet.aptoslabs.com/decibel
    description: Mainnet
  - url: https://api.testnet.aptoslabs.com/decibel
    description: Testnet
security:
  - bearerAuth: []
tags:
  - name: Market Data
    description: Market information and real-time data endpoints
  - name: User
    description: User information and account management
  - name: Account
    description: Account-specific endpoints and data
  - name: Trades
    description: Trading operations and history
  - name: Positions
    description: User position management
  - name: Orders
    description: Order management and history
  - name: TWAP
    description: Time-weighted average price orders
  - name: Bulk Orders
    description: Bulk order management
  - name: Vaults
    description: Vault operations and management
  - name: Analytics
    description: Analytics and performance metrics
  - name: Points
    description: Points-related account metrics
  - name: Trading Points
    description: Trading points endpoints
  - name: Trading Hz
    description: Trading Hz endpoints
  - name: Tier
    description: Tier information endpoints
  - name: Streaks
    description: User streak tracking endpoints
  - name: Predeposit Rewards
    description: Season 0 predeposit USDC rewards
  - name: Referrals
    description: Referral code management and tracking
  - name: Affiliates
    description: Affiliate code and earnings endpoints
  - name: Campaigns
    description: On-chain reward campaign endpoints
paths:
  /api/v1/trades/window:
    get:
      tags:
        - Market Data
      summary: Get trades in a time window
      description: >-
        A perp market's fills between two timestamps, newest first, optionally
        only those worth at

        least `min_notional_usd`. The window can be at most 31 days. Both legs
        of a fill are returned.
      operationId: handle_trades_window
      parameters:
        - name: market
          in: query
          description: Perp market address
          required: true
          schema:
            type: string
          example: 0xmarket123...
        - name: from_ms
          in: query
          description: Window start, unix ms (inclusive)
          required: true
          schema:
            type: integer
            format: int64
        - name: to_ms
          in: query
          description: Window end, unix ms (inclusive)
          required: true
          schema:
            type: integer
            format: int64
        - name: min_notional_usd
          in: query
          description: Only fills worth at least this many USD
          required: false
          schema:
            type: number
            format: double
          example: 100
        - name: limit
          in: query
          description: Max fills, newest first
          required: false
          schema:
            type: integer
            format: int32
            default: 500
            maximum: 1000
            minimum: 1
      responses:
        '200':
          description: Fills in the window
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TradeDto'
        '400':
          description: Invalid market or window
        '500':
          description: Database error
components:
  schemas:
    TradeDto:
      type: object
      required:
        - asset_type
        - account
        - market
        - action
        - source
        - trade_id
        - size
        - price
        - is_profit
        - realized_pnl_amount
        - realized_funding_amount
        - is_rebate
        - fee_amount
        - order_id
        - client_order_id
        - transaction_unix_ms
        - transaction_version
        - counter_party_account
      properties:
        account:
          type: string
          description: User's account address
          example: '0x1234567890abcdef1234567890abcdef12345678'
        action:
          type: string
          description: >-
            Trade action type. Perp: position-centric ("OpenLong", "CloseShort",

            "Net", ...). Spot: side from this row's perspective ("Buy" /
            "Sell").
          example: buy
        asset_type:
          $ref: '#/components/schemas/AssetType'
          description: >-
            Which product this trade belongs to ("perp" or "spot"). Responses
            can

            mix products; this per-row tag lets clients demux.
        client_order_id:
          type: string
          description: Client-specified order ID
          example: client_order_abc
        counter_party_account:
          type: string
          description: >-
            Counter party account on the other leg of the fill. For liquidation
            /

            ADL / delisting fills this is the backstop liquidator. Empty string
            for

            pre-V2 historical trades that did not carry counter party on-chain.
          example: '0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210'
        fee_amount:
          type: number
          format: double
          description: |-
            Fee paid by this row's account, normalized. Perp: always in the
            collateral asset (USDC). Spot: charged in the asset this side
            RECEIVED (protocol + builder fee combined); see `fee_asset`.
        fee_asset:
          type:
            - string
            - 'null'
          description: |-
            FA metadata address of the asset `fee_amount` is denominated in.
            Spot only (base asset for the buyer, quote for the seller); absent
            for perp rows, where the fee is implicitly the collateral asset.
        is_profit:
          type: boolean
          description: Whether trade was profitable
        is_rebate:
          type: boolean
          description: Whether trade received rebate
        market:
          type: string
          description: Market identifier address
          example: 0xmarket123456789abcdef
        order_id:
          type: string
          description: Order ID associated with trade
          example: '12345'
        price:
          type: number
          format: double
          description: Trade price
          example: 50000.25
        realized_funding_amount:
          type: number
          format: double
          description: >-
            Realized funding amount in USDC

            - Negative value: trader PAID funding (e.g., long position with
            positive funding rate)

            - Positive value: trader RECEIVED funding (e.g., short position with
            positive funding rate)

            - Zero: no funding accrued
          example: -15.5
        realized_pnl_amount:
          type: number
          format: double
          description: Realized PnL amount
        size:
          type: number
          format: double
          description: Trade size
          example: 100.5
        source:
          type: string
          description: >-
            Trade source (e.g., "OrderFill", "MarginCall",
            "BackStopLiquidation", "ADL", "MarketDelisted")
          example: OrderFill
        trade_id:
          type: string
          description: Trade ID
          example: '3647276'
        transaction_unix_ms:
          type: integer
          format: int64
          description: Transaction timestamp in milliseconds
          example: 1634567890000
        transaction_version:
          type: integer
          format: int64
          description: Transaction version
          example: 3647276285
          minimum: 0
    AssetType:
      type: string
      description: >-
        Discriminator carried on DTOs that can mix perp and spot rows (markets,

        orders, trades, bulk orders, bulk order fills, and WebSocket payloads).

        Also accepted as a query parameter on REST endpoints that can filter to
        one

        product.


        Wire format is lowercase (`"perp"` / `"spot"`) and accepted

        case-insensitively on the request side via
        [`impl_case_insensitive_deserialize`].
      enum:
        - perp
        - spot
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token from Geomi. See
        [Authentication](/api-reference/rest/authentication) for setup
        instructions.

````

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