API reference · v5

dYdX API

dYdX v4 by address: equity, PnL and equity charts, open positions including isolated ones, closed positions, orders and transfers.

Base URL https://api.kopyon.com/v5/dydx/ · send your key in the X-API-KEY header · trader id: A dYdX address (dydx1…).

Get a free API key · Interactive reference with Try it · Authentication, paging and errors

Trader profile

GET /v5/dydx/traderProfile

The address's equity and free collateral across its subaccounts. dYdX has no leaderboard, names or follower counts.

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)

Response fields, in data

FieldTypeDescription
traderIdalwaysstring
sourceDetails.equityonly dYdX
sourceDetails.freeCollateralonly dYdX
sourceDetails.openPositionsonly dYdX
sourceDetails.subaccountsonly dYdX

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/traderProfile?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj"
{
  "data": {
    "traderId": "dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj",
    "sourceDetails": {
      "equity": 1639.497175037,
      "freeCollateral": 1616.4667255687,
      "openPositions": 2,
      "subaccounts": 1
    }
  }
}

Trader chart

GET /v5/dydx/traderChart

Hourly all-time PnL or equity over the period, oldest first.

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)
periodrequiredenumDays back from now1D, 7D, 30D
metricenumdefault pnlAll-time PnL or equity, in USDCpnl, equity

Response fields, in data

FieldTypeDescription
metricalwaysstringWhat the points measure: ROI, PNL or BALANCE
points[]alwaysarray
points[].timestampalwaysnumberPoint time, in Unix milliseconds
points[].valuealwaysnumber

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/traderChart?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj&period=1D"
{
  "data": {
    "metric": "PNL",
    "points": [
      {
        "timestamp": 1792252893509,
        "value": 696.516078
      },
      {
        "timestamp": 1792256468148,
        "value": 697.894377
      },
      {
        "timestamp": 1792260053544,
        "value": 696.755782
      }
    ]
  }
}

Open positions

GET /v5/dydx/openPositions

Open perpetual positions in every subaccount, cross and isolated, marked at dYdX's oracle price.

dYdX refreshes this dYdX's indexer updates these positions every 5 s..

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)

Response fields, in data

FieldTypeDescription
positions[]alwaysarray
positions[].symbolalwaysstring
positions[].sidealwaysLONG | SHORT
positions[].sizenumberPosition size, always positive; side gives the direction
positions[].entryPricealwaysnumber
positions[].markPricenumberThe exchange's mark price
positions[].marginModeISOLATED | CROSS
positions[].unrealizedPnlnumberIn pnlCurrency
positions[].pnlCurrencystring
positions[].liquidationPricenumber
positions[].sourceDetails.subaccountNumberonly dYdX
positions[].sourceDetails.realizedPnlonly dYdX
positions[].openedAtnumber
positions[].fundingPnlnumber

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/openPositions?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj"
{
  "data": {
    "positions": [
      {
        "symbol": "APEUSD",
        "side": "SHORT",
        "size": 82,
        "entryPrice": 0.607,
        "markPrice": 0.13637496,
        "marginMode": "CROSS",
        "unrealizedPnl": 38.59125328,
        "pnlCurrency": "USDC",
        "openedAt": 1751225227428,
        "fundingPnl": 0.041164,
        "sourceDetails": {
          "subaccountNumber": 0,
          "realizedPnl": 0
        }
      },
      {
        "symbol": "WIFUSD",
        "side": "SHORT",
        "size": 1081,
        "entryPrice": 0.811,
        "markPrice": 0.192358003,
        "marginMode": "CROSS",
        "unrealizedPnl": 668.751998757,
        "pnlCurrency": "USDC",
        "openedAt": 1751131423874,
        "fundingPnl": -3.595406,
        "sourceDetails": {
          "subaccountNumber": 0,
          "realizedPnl": 0
        }
      }
    ]
  }
}

Position history

GET /v5/dydx/positionHistory

Closed positions, newest first, with funding and, when the whole position closed, the gross PnL worked out from the average prices. Fees are in orderHistory.

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)
cursorstringThe nextCursor of the previous answer; leave it out for the first page
rowsintdefault 20Rows per page1 to 100

Response fields, in data

FieldTypeDescription
positions[]alwaysarray
positions[].positionIdstring
positions[].symbolalwaysstring
positions[].sideLONG | SHORT
positions[].statusstring
positions[].marginModeISOLATED | CROSS
positions[].leveragenumber
positions[].roinumber
positions[].entryPricenumber
positions[].closePricenumber
positions[].openedAtalwaysnumberWhen the position opened, in Unix milliseconds
positions[].closedAtnumberWhen the position closed, in Unix milliseconds
positions[].updatedAtalwaysnumberLast change, in Unix milliseconds
positions[].openedVolumenumber
positions[].closedVolumenumber
positions[].maxOpenInterestnumber
positions[].grossPnlnumber
positions[].fundingPnlnumber
positions[].tradingFeenumber
positions[].liquidationFeenumber
positions[].netPnlnumber
positions[].pnlCurrencystring
positions[].sourceDetails.subaccountNumberonly dYdX
nextCursorstringSend it back as cursor, with the same query, to read the next page; absent on the last page

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/positionHistory?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj"
{
  "data": {
    "positions": []
  }
}

Transfer history

GET /v5/dydx/transferHistory

Deposits, withdrawals and transfers to or from other addresses, newest first. Moves between the address's own subaccounts are left out, so a page can hold fewer rows than asked.

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)
cursorstringThe nextCursor of the previous answer; leave it out for the first page
rowsintdefault 20Rows per page1 to 100

Response fields, in data

FieldTypeDescription
transfers[]alwaysarray
transfers[].timealwaysnumberIn Unix milliseconds
transfers[].assetstring
transfers[].amountalwaysnumber
transfers[].typealwaysdeposit | withdraw | transfer | vaultDeposit | vaultWithdraw | commission | otherdeposit and withdraw move the owner's money into or out of the account; transfer, to or from another address; vaultDeposit and vaultWithdraw, into or out of a vault; commission is a vault leader's share; other is a kind none of these fits, named in sourceDetails.type
transfers[].sourceDetails.typeonly dYdX
transfers[].counterpartystring
transfers[].txHashstring
nextCursorstringSend it back as cursor, with the same query, to read the next page; absent on the last page

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/transferHistory?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj"
{
  "data": {
    "transfers": [
      {
        "time": 1751143257268,
        "amount": 58.541965,
        "asset": "USDC",
        "type": "deposit",
        "sourceDetails": {
          "type": "DEPOSIT"
        },
        "txHash": "897D548E649B748616EE1E622FAC1F51694550518CD682DA99573655C1017DD1"
      },
      {
        "time": 1751131233450,
        "amount": 877.278757,
        "asset": "USDC",
        "type": "deposit",
        "sourceDetails": {
          "type": "DEPOSIT"
        },
        "txHash": "5B0981B92651F19E758A8CB186C558F6DEE6A919FFE28F0F5F5D5303B11B1784"
      }
    ]
  }
}

Order history

GET /v5/dydx/orderHistory

Filled perpetual orders, newest first, built from the latest fills (up to 1000): average price, quantity and fees. The oldest order may be missing fills read past the limit. dYdX offers no way to page further back.

Query parameters

NameTypeDescription
traderIdrequiredstringA dYdX address (dydx1...)
rowsintdefault 500Latest fills to read1 to 1000

Response fields, in data

FieldTypeDescription
orders[]alwaysarray
orders[].symbolalwaysstring
orders[].sidealwaysstring
orders[].positionSidestringBOTH in one-way mode; LONG or SHORT in hedge mode
orders[].pricenumber
orders[].quantitynumber
orders[].quoteQuantitynumber
orders[].createdAtnumberWhen the order was placed, in Unix milliseconds
orders[].updatedAtalwaysnumberLast change, in Unix milliseconds
orders[].sourceDetails.fillsonly dYdX
orders[].orderTypestringFor example MARKET or LIMIT
orders[].orderIdstring
orders[].tradingFeenumberFees paid, in sourceDetails.feeToken; negative is a rebate

Example

curl -H "X-API-KEY: $KOPYON_KEY" \
  "https://api.kopyon.com/v5/dydx/orderHistory?traderId=dydx1000qkj0ns34zk9706plzq4vk07kmgvkdaruddj"
{
  "data": {
    "orders": [
      {
        "symbol": "APEUSD",
        "side": "SELL",
        "positionSide": "BOTH",
        "price": 0.607,
        "quantity": 82,
        "quoteQuantity": 49.774,
        "createdAt": 1751225227428,
        "updatedAt": 1751225227428,
        "orderId": "b5032e25-fa1a-5595-aee5-68f387c0ed58",
        "orderType": "LIMIT",
        "tradingFee": 0.024887,
        "sourceDetails": {
          "fills": 1
        }
      },
      {
        "symbol": "WIFUSD",
        "side": "SELL",
        "positionSide": "BOTH",
        "price": 0.811,
        "quantity": 1081,
        "quoteQuantity": 876.691,
        "createdAt": 1751131423874,
        "updatedAt": 1751131423874,
        "orderId": "1ff415d3-3015-50c5-87e1-4dc63b38211b",
        "orderType": "LIMIT",
        "tradingFee": 0.08767,
        "sourceDetails": {
          "fills": 1
        }
      }
    ]
  }
}

Stream and webhooks

Paid plans can follow a trader in real time over wss://api.kopyon.com/v5/streamor through signed webhooks. Topics for this source:

  • openPositions: Open positions, whenever they change
  • positionEvents: Opened, increased, decreased, closed
  • orderHistory: New and updated orders
  • positionHistory: Newly closed positions

Stream messages and webhook signatures

Try the dYdX API for free.

The free tier is 10,000 requests a month. That is enough to build a whole integration and test it against live data before you pay anything.

Usually answered within a day · [email protected]