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

# Settled trades

> Settled trades of the last 48 hours, newest first. A page holds at most 100 rows. Page with `beforeSlot`.



## OpenAPI

````yaml /openapi/data-api.json get /v0/trades
openapi: 3.1.0
info:
  title: Rekt data API
  version: '0'
  summary: Read-only HTTP API for settled trades and ended positions.
  description: >-
    `https://data.rekt.trading` serves settled trades and ended positions. It is
    read-only and it needs no account. It sets no cookies and accepts no
    credentials. Responses carry `Access-Control-Allow-Origin: *`. Start at `GET
    /v0/health`.


    The program is the ground of truth. This API is a lagging mirror of it. Read
    live state from the chain through the SDK.


    Rules:


    - Every route answers `GET`, `HEAD` and `OPTIONS`. Any other method gets
    `405`.

    - A request URL is at most 2,048 characters. A longer one gets `414`.

    - Requests are rate-limited for each client address. `GET /v0/health` states
    the limit under `access`. A request over it gets `429` and a `Retry-After`
    header. Wait that long, then retry.

    - This API ignores a parameter that it does not know. A filter that this API
    refuses gets `400`.

    - Money amounts are decimal strings of base units of USDC (6 decimals).
    Addresses are 64 hex characters unless a field says base58. Transaction
    signatures are base58.

    - A response can hold fields that this description does not list. Ignore a
    field that you do not know.
servers:
  - url: https://data.rekt.trading
    description: The data API.
security: []
tags:
  - name: Health
    description: Freshness and limits.
  - name: Aggregates
    description: All-time totals and day series.
  - name: Trades
    description: Settled trades of the last 48 hours.
  - name: Positions
    description: Ended positions of the last 48 hours.
  - name: Minute
    description: Minute rounds of the last 48 hours.
paths:
  /v0/trades:
    get:
      tags:
        - Trades
      summary: Settled trades
      description: >-
        Settled trades of the last 48 hours, newest first. A page holds at most
        100 rows. Page with `beforeSlot`.
      operationId: listTrades
      parameters:
        - $ref: '#/components/parameters/owner'
        - $ref: '#/components/parameters/market'
        - $ref: '#/components/parameters/beforeSlot'
        - $ref: '#/components/parameters/limit50'
        - name: format
          in: query
          required: false
          description: Send `ndjson` to get one trade on each line, with no envelope.
          schema:
            type: string
            enum:
              - ndjson
      responses:
        '200':
          description: >-
            A page of settled trades. With `format=ndjson` the body is one trade
            row (`TradeRow`) on each line, with no envelope. The `X-Asof-*`
            headers carry the freshness.
          headers:
            Cache-Control:
              description: '`public, max-age=5`.'
              schema:
                type: string
            Warning:
              description: >-
                Present only when `asOf.stale` is true. It states that the
                archive is stale.
              schema:
                type: string
            X-Asof-Slot:
              description: 'With `format=ndjson` only: `asOf.archiveTailSlot`. Unit: slots.'
              schema:
                type: string
            X-Asof-At:
              description: 'With `format=ndjson` only: `asOf.archiveTailAt`.'
              schema:
                type: string
            X-Asof-Stale:
              description: 'With `format=ndjson` only: `asOf.stale`, as `true` or `false`.'
              schema:
                type: string
            X-Indexer-Window-Hours:
              description: 'With `format=ndjson` only: the window. Unit: hours.'
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TradesResponse'
            application/x-ndjson:
              schema:
                type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '414':
          $ref: '#/components/responses/UriTooLong'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  parameters:
    owner:
      name: owner
      in: query
      required: false
      description: >-
        Return only the rows of this wallet. Give the wallet as base58 or as 64
        hex characters. Any other value matches nothing: the page is empty and
        `filters.owner` repeats the value.
      schema:
        type: string
    market:
      name: market
      in: query
      required: false
      description: >-
        Return only the rows of this market. Give the market account address as
        64 hex characters.
      schema:
        type: string
    beforeSlot:
      name: beforeSlot
      in: query
      required: false
      description: >-
        Return only the rows before this slot. To get the next page, send
        `nextBeforeSlot` from the previous page. Unit: slots.
      schema:
        type: integer
        minimum: 0
    limit50:
      name: limit
      in: query
      required: false
      description: >-
        The number of rows in the page. The server reads a value above 100 as
        100.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 50
  schemas:
    TradesResponse:
      type: object
      description: A page of settled trades, newest first.
      properties:
        asOf:
          $ref: '#/components/schemas/AsOf'
        tier:
          type: string
          description: >-
            The access tier that answered. It is `public` for a caller without a
            key.
          enum:
            - public
        window:
          $ref: '#/components/schemas/Window'
        filters:
          type: object
          description: >-
            The filters of this request, as sent. A filter that was not sent is
            null.
          properties:
            owner:
              type:
                - string
                - 'null'
              description: The `owner` filter.
            market:
              type:
                - string
                - 'null'
              description: The `market` filter.
            beforeSlot:
              type:
                - string
                - 'null'
              description: The `beforeSlot` filter, as sent.
            limit:
              type: integer
              description: 'The page size that applied. Unit: rows.'
        sampleSize:
          type: integer
          description: 'The number of rows in this page. Unit: rows.'
        totalMatching:
          type: integer
          description: 'The number of rows in the window that match the filters. Unit: rows.'
        nextBeforeSlot:
          type:
            - integer
            - 'null'
          description: >-
            Send this value as `beforeSlot` to get the next page. Null on the
            last page. Unit: slots.
        trades:
          type: array
          description: The trades, newest first.
          items:
            $ref: '#/components/schemas/TradeRow'
      required:
        - asOf
        - tier
        - window
        - filters
        - sampleSize
        - totalMatching
        - nextBeforeSlot
        - trades
    AsOf:
      type: object
      description: How fresh the archive is at the time of this response.
      properties:
        generatedAt:
          type: string
          description: The time the server made this response, in UTC (ISO 8601).
          format: date-time
        archiveTailSlot:
          type:
            - integer
            - 'null'
          description: >-
            The slot of the newest transaction in the archive. Unit: slots. Null
            when the archive is empty.
        archiveTailAt:
          type:
            - string
            - 'null'
          description: >-
            The block time of the newest transaction in the archive, in UTC (ISO
            8601). Null when the archive is empty.
          format: date-time
        stale:
          type: boolean
          description: >-
            True when the archive has not moved for longer than its freshness
            limit. The server still sends a stale response, with a `Warning`
            header.
        staleReason:
          type:
            - string
            - 'null'
          description: Why the archive is stale, in words. Null when `stale` is false.
        entryFeeBasis:
          type: string
          description: >-
            How the entry fees in the rows were found. `observed` means each fee
            is the fee that the trade paid. Only the routes whose rows carry an
            entry fee send this field.
          enum:
            - observed
      required:
        - generatedAt
        - archiveTailSlot
        - archiveTailAt
        - stale
        - staleReason
    Window:
      type: object
      description: The time window of a per-transaction route.
      properties:
        hours:
          type: integer
          description: 'The length of the window. Unit: hours.'
          examples:
            - 48
        since:
          type: string
          description: >-
            The start of the window, in UTC (ISO 8601). The route does not send
            rows before this time.
          format: date-time
        rule:
          type: string
          description: The window rule, in words.
      required:
        - hours
        - since
        - rule
    TradeRow:
      type: object
      description: One settled trade.
      properties:
        kind:
          type: string
          description: The row type. It is always `trade`.
          enum:
            - trade
        at:
          type: string
          description: The settlement time, in UTC (ISO 8601).
          format: date-time
        signature:
          type: string
          description: The signature of the settle transaction, in base58.
        owner:
          type: string
          description: The wallet that owned the position, as 64 hex characters.
          pattern: ^[0-9a-f]{64}$
        market:
          type: string
          description: The market account address, as 64 hex characters.
          pattern: ^[0-9a-f]{64}$
        seq:
          type: string
          description: >-
            The position number of this owner. `owner` and `seq` identify the
            trade. A decimal string.
          pattern: ^[0-9]+$
        openedAt:
          type:
            - integer
            - 'null'
          description: >-
            The open time. Unit: Unix seconds. Null when the archive holds no
            open for this trade.
        openedSlot:
          type:
            - integer
            - 'null'
          description: >-
            The slot of the open transaction. Unit: slots. Null when the archive
            holds no open for this trade.
        openSignature:
          type:
            - string
            - 'null'
          description: >-
            The signature of the open transaction, in base58. Null when the
            archive holds no open for this trade.
        settledAt:
          type:
            - integer
            - 'null'
          description: 'The block time of the settle transaction. Unit: Unix seconds.'
        settledSlot:
          type: integer
          description: >-
            The slot of the settle transaction. Unit: slots. Pages are in this
            order, newest first.
        direction:
          type:
            - string
            - 'null'
          description: The side of the position. Null when the settlement does not show it.
          enum:
            - long
            - short
            - null
        rungBps:
          type: integer
          description: >-
            The rung of the position. Unit: basis points of the stake (20,000 is
            2.00x).
        tier:
          type:
            - string
            - 'null'
          description: >-
            The leverage tier of the position, as a decimal string (`1000` is
            1000x). Null when the settlement does not show it.
          pattern: ^[0-9]+$
        stake:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The stake of the position. Unit: base units of USDC (6 decimals), as
            a decimal string.
        entryPrice:
          type: string
          description: >-
            The entry price, as a decimal string at the price scale of the
            market.
          pattern: ^[0-9]+$
        exitPrice:
          type: string
          description: >-
            The exit price, as a decimal string at the price scale of the
            market.
          pattern: ^[0-9]+$
        reason:
          type: string
          description: >-
            Why the position closed: `voluntary`, `knockout`, `takeProfit`,
            `userExpiry`, `tenorExpiry`, `lastResort` or `borrowSpent`.
        capped:
          type: boolean
          description: True when the payout cap of the engine limited this payout.
        payouts:
          type: object
          description: What the settlement paid.
          properties:
            trader:
              type: string
              pattern: ^[0-9]+$
              description: >-
                The amount that the settlement paid the trader in its own
                transaction. Unit: base units of USDC (6 decimals), as a decimal
                string.
        breakdown:
          $ref: '#/components/schemas/Breakdown'
        entryFee:
          type:
            - string
            - 'null'
          pattern: ^[0-9]+$
          description: >-
            The entry fee that the trade paid at open. Null when it is not
            known. Unit: base units of USDC (6 decimals), as a decimal string.
        timerFee:
          type:
            - string
            - 'null'
          pattern: ^[0-9]+$
          description: >-
            The timer fee that the trade paid at open. Null when it is not
            known. Unit: base units of USDC (6 decimals), as a decimal string.
        reconstruction:
          type: object
          description: The result of the engine replay.
          properties:
            verified:
              type: boolean
              description: >-
                True when the replayed engine gave the same payouts as the
                program.
        receipt:
          $ref: '#/components/schemas/Receipt'
        queue:
          $ref: '#/components/schemas/QueueBlock'
      required:
        - kind
        - at
        - signature
        - owner
        - market
        - seq
        - settledSlot
        - stake
        - reason
        - payouts
        - reconstruction
    Error:
      type: object
      description: A refused request.
      properties:
        error:
          type: string
          description: What is wrong, in words.
        retryAfterSeconds:
          type: integer
          description: 'On `429` only: wait this long, then retry. Unit: seconds.'
        routes:
          type: array
          items:
            type: string
          description: 'On `404` for an unknown route only: the routes that this API serves.'
      required:
        - error
    Breakdown:
      type:
        - object
        - 'null'
      description: >-
        The settlement money, step by step, from the replayed engine. Null when
        the replay could not confirm the settlement.
      properties:
        collateral:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The stake of the position. Unit: base units of USDC (6 decimals), as
            a decimal string.
        notional:
          type: string
          pattern: ^[0-9]+$
          description: >-
            `collateral × tier`: the amount that the price move applied to.
            Unit: base units of USDC (6 decimals), as a decimal string.
        grossPnl:
          type: string
          pattern: ^-?[0-9]+$
          description: >-
            What the price move earned before any fee or tax. Unit: base units
            of USDC (6 decimals), as a signed decimal string.
        lossTax:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The loss tax. It is zero when no loss occurred. Unit: base units of
            USDC (6 decimals), as a decimal string.
        exitFee:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The exit fee, as the program charged it. Unit: base units of USDC (6
            decimals), as a decimal string.
        net:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The amount that the trader got back at settlement. Unit: base units
            of USDC (6 decimals), as a decimal string.
        netPnl:
          type: string
          pattern: ^-?[0-9]+$
          description: >-
            `net - collateral`. It does not include the entry fee. Unit: base
            units of USDC (6 decimals), as a signed decimal string.
    Receipt:
      type: object
      description: The receipt that the program wrote for this settlement.
      properties:
        exitFeeTotal:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The exit fee that the settlement charged. Unit: base units of USDC
            (6 decimals), as a decimal string.
        lossTaxTotal:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The loss tax that the settlement charged. Unit: base units of USDC
            (6 decimals), as a decimal string.
        payoutTrader:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The amount that the settlement paid the trader. Unit: base units of
            USDC (6 decimals), as a decimal string.
        priceKind:
          type:
            - string
            - 'null'
          description: >-
            The name of the price source that priced the settlement. Null when
            no price priced it.
        tick:
          description: >-
            The tick that priced the settlement. Null when the price source
            states no tick.
          anyOf:
            - $ref: '#/components/schemas/Tick'
            - type: 'null'
    QueueBlock:
      type: object
      description: >-
        The payout queue facts of a settlement that queued part of a win. Only a
        settlement that queued money carries this block.
      properties:
        owed:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The whole amount that the settlement owes the trader. Unit: base
            units of USDC (6 decimals), as a decimal string.
        paidNow:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The part of `owed` that the settlement paid in its own transaction.
            Unit: base units of USDC (6 decimals), as a decimal string.
        queued:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The part of `owed` that went into the payout queue. Unit: base units
            of USDC (6 decimals), as a decimal string.
        delivered:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The queued amount that later payments delivered to the trader. Unit:
            base units of USDC (6 decimals), as a decimal string.
        escrowed:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The queued amount that later payments set aside because the program
            could not deliver it. Unit: base units of USDC (6 decimals), as a
            decimal string.
        outstanding:
          type: string
          pattern: ^[0-9]+$
          description: >-
            The queued amount that is still owed: `queued - delivered -
            escrowed`. Unit: base units of USDC (6 decimals), as a decimal
            string.
        status:
          type: string
          description: Where the queued amount stands.
          enum:
            - in-full
            - parked
            - waiting
            - part-funded
            - funded
            - part-paid
            - paid
    Tick:
      type: object
      description: >-
        The price tick that priced this step, when the price source of the
        market states one.
      properties:
        role:
          type: string
          description: >-
            What the tick priced: `fill`, `void-proof`, `window`, `level`,
            `add-fill` or `reverse-proof`. `unknown` is a role that this server
            cannot name.
        tickUs:
          type: string
          description: >-
            The time of the tick. Unit: microseconds since the Unix epoch, as a
            decimal string.
          pattern: ^[0-9]+$
        targetUs:
          type:
            - string
            - 'null'
          description: >-
            The time that the request asked for. Unit: microseconds since the
            Unix epoch, as a decimal string. Null when the step asked for no
            time.
          pattern: ^[0-9]+$
        channel:
          type: integer
          description: The channel number of the tick.
        session:
          type: integer
          description: The market session code of the tick. 0 is the regular session.
        updateAgeUs:
          type: string
          description: >-
            The age of the tick content when the program read it. Unit:
            microseconds, as a decimal string.
          pattern: ^[0-9]+$
        slot:
          type: string
          description: >-
            The slot where the instruction that read the tick landed. Unit:
            slots, as a decimal string.
          pattern: ^[0-9]+$
  responses:
    BadRequest:
      description: >-
        The request used a filter that this API refuses, or the path, the
        signature or `phase` is not valid. Fix the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UriTooLong:
      description: The request URL is longer than 2,048 characters. Shorten it.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: >-
        Too many requests. Wait `Retry-After` seconds, then retry. `GET
        /v0/health` states the limit under `access`.
      headers:
        Retry-After:
          description: 'Wait this long before you retry. Unit: seconds.'
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: The server could not answer. Retry later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

````

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