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

# Get Perpetual Trades

> Get perpetual trade history

> [!NOTE]
>
> **10** credits per request

***

> **You will get**
>
> * Synced exchange trade records with prices, realized P\&L and fees where available

> **Optional**
>
> * portfolioId: Owned exchange or parent from GET /portfolio/list. Omit for all owned exchanges.
> * limit: 1 to 100, default 20. skip: 0 to 10000, default 0.

> **History coverage**
>
> * Uses the last portfolio sync and existing connector coverage. Records may group executions into positions. Unavailable fields are null; funding payments are not included.
> * Realized P\&L follows the connector basis. BingX includes trading fees and funding; do not subtract fees again without checking the connector basis.
> * Newest first by opening time. Use nextSkip for another page; new records can shift offsets and a full page may be followed by an empty page.


## OpenAPI

````yaml /api-docs/api-reference/openapi.json get /v1/portfolio/perpetual/trades
openapi: 3.0.0
info:
  title: CoinStats Public API
  description: >-
    CoinStats Public API — programmatic access to market data, news, NFTs,
    wallets, exchange connections, and user portfolios. Authenticate every
    request with the `X-API-KEY` header (or an OAuth Bearer token in the
    `Authorization` header). Generate keys at https://openapi.coinstats.app.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.coinstats.app
security: []
tags:
  - name: CoinStats
    description: ''
  - name: Market Data
    description: >-
      The Market Data section of the API provides endpoints to access a wide
      range of market-related information, including cryptocurrency coins,
      ticker data, and fiat currency rates. This category offers comprehensive
      data to help users monitor and analyze the cryptocurrency market, track
      prices, and gain insights into market trends
  - name: RWA
    description: >-
      Tokenized real-world assets: overview, stocks, commodities, ETFs, tokens,
      trading markets, and aggregate or per-asset history.
  - name: News
    description: >-
      The News section of the API allows you to access news articles and updates
      related to cryptocurrencies and the blockchain industry. It provides
      valuable information from various sources to keep you informed about the
      latest developments
  - name: NFTs
    description: >-
      The NFT section of the API provides endpoints to interact with
      Non-Fungible Tokens (NFTs), which are unique digital assets stored on a
      blockchain. These endpoints allow you to retrieve information about NFTs,
      including collections, assets, trending NFTs, and specific assets
      associated with wallet addresses.
  - name: Wallet NFTs
    description: >-
      NFTs held by a wallet: tokens, collections, value, activity and token
      gating
  - name: Wallet Data
    description: >-
      The Wallet section of the API provides a comprehensive set of endpoints to
      manage and interact with wallets. It enables users to retrieve wallet
      balances, monitor syncing status, fetch transaction data, and synchronize
      wallet information with the blockchain. By integrating these endpoints
      into your application, you can offer robust wallet functionality to your
      users.
  - name: Exchange Connection
    description: >-
      The Exchange Connection section of the API provides a comprehensive set of
      endpoints to manage and interact with exchanges. It enables users to
      retrieve exchange balances, monitor syncing status, fetch transaction
      data. By integrating these endpoints into your application, you can offer
      robust exchange portfolio tracking functionality to your users.
  - name: User Portfolio
    description: >-
      The Portfolio section of the API provides a comprehensive set of endpoints
      to manage and interact with Share Portfolios. It enables users to retrieve
      current Portfolio Coins and Transactions.
  - name: Usage
    description: The Usage section provides account-level API usage data.
  - name: Status
    description: The Status section provides API availability checks.
  - name: Prediction · Markets
    description: >-
      Polymarket, Kalshi and Polymarket US markets: list/trend/detail, live
      prices and order book, OHLC candles, and price history. `view` picks the
      venues a list shows (`intl` default, `us`, `all`). Prices are
      probabilities in 0..1, money is USD, dates are ISO 8601.
  - name: Prediction · Events
    description: >-
      Polymarket, Kalshi and Polymarket US events — groups of related markets
      (e.g. one market per candidate). List, trend, and fetch an event with its
      child markets.
  - name: Prediction · Traders
    description: >-
      Trader leaderboard plus deep per-trader analytics: profile, open
      positions, trade history, daily PnL, category stats, aggregate trade
      stats, and composite score.
  - name: Prediction · Analytics
    description: >-
      Platform-wide analytics: overview stats, smart-money and whale traders,
      trending-by-smart-money markets, and composite market signals.
  - name: Prediction · Search
    description: Full-text search across prediction-market events, markets, and traders.
paths:
  /v1/portfolio/perpetual/trades:
    get:
      tags:
        - User Portfolio
      summary: Get perpetual trade history
      operationId: get-perpetual-trades
      parameters:
        - name: portfolioId
          required: false
          in: query
          description: >-
            Owned exchange or parent portfolio from GET /portfolio/list. Omit
            for all owned exchanges.
          schema:
            type: string
        - name: limit
          required: false
          in: query
          schema:
            minimum: 1
            maximum: 100
            default: 20
            type: integer
        - name: skip
          required: false
          in: query
          schema:
            minimum: 0
            maximum: 10000
            default: 0
            type: integer
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerpetualTradesResponseDto'
        '400':
          description: Bad Request
          content:
            application/json:
              example:
                statusCode: 400
                message: Bad Request
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                statusCode: 401
                message: Unauthorized
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '403':
          description: Forbidden
          content:
            application/json:
              example:
                statusCode: 403
                message: Forbidden
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '404':
          description: Not Found
          content:
            application/json:
              example:
                statusCode: 404
                message: Not Found
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '409':
          description: Conflict (for some endpoints)
          content:
            application/json:
              example:
                statusCode: 409
                message: Transactions not synced
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                statusCode: 429
                message: Rate limit exceeded
                requestId: 11111111-2222-3333-4444-555555555555
                path: <requested-endpoint>
        '503':
          description: Service Unavailable
          content:
            application/json:
              example:
                statusCode: 503
                message: Service Unavailable. Please Contact Support
      security:
        - X-API-KEY: []
components:
  schemas:
    PerpetualTradesResponseDto:
      type: object
      properties:
        trades:
          type: array
          items:
            $ref: '#/components/schemas/PerpetualTradeDto'
        nextSkip:
          type: number
          nullable: true
          description: >-
            Next offset, or null at the end or the offset limit. A full page may
            be followed by an empty page.
      required:
        - trades
        - nextSkip
    PerpetualTradeDto:
      type: object
      properties:
        id:
          type: string
        portfolioId:
          type: string
        coinId:
          type: string
        quoteCoinId:
          type: string
        symbol:
          type: string
          nullable: true
        side:
          type: string
          nullable: true
          enum:
            - long
            - short
        action:
          type: string
          nullable: true
          description: Connector close type, such as Closed or Liquidation.
        size:
          type: number
        entryPrice:
          type: number
          nullable: true
        closePrice:
          type: number
          nullable: true
        leverage:
          type: number
          nullable: true
        realizedPnlUsd:
          type: number
          nullable: true
          description: >-
            Connector-reported realized P&L. Fee and funding treatment varies by
            connector; BingX includes both. Do not subtract fees again without
            checking the connector basis.
        tradingFeeUsd:
          type: number
          nullable: true
        timestamp:
          type: number
          description: Record opening time in Unix milliseconds.
        closedAt:
          type: number
          nullable: true
          description: Record closing time in Unix milliseconds.
      required:
        - id
        - portfolioId
        - symbol
        - side
        - action
        - size
        - entryPrice
        - closePrice
        - leverage
        - realizedPnlUsd
        - tradingFeeUsd
        - timestamp
        - closedAt
  securitySchemes:
    X-API-KEY:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        API key required to access the endpoints. Generate one from your
        dashboard at https://openapi.coinstats.app and pass it in the
        `X-API-KEY` request header. Never expose your key in client-side code.

````

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