Skip to content

IndexerData

HTTP methods exposed under Indexer.data.

Indexer.data includes endpoint methods along with convenience helpers such as get_market, get_open_position, and the *_paged iterators.

Market And Utility Methods

get_markets

Retrieve perpetual market metadata from the indexer. When market is provided, the request filters to a single market.

  • market: Specific market ticker to retrieve, for example BTC-USD.
  • limit: Maximum number of market entries to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_markets.py
async def get_markets(
  self,
  *,
  market: str | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> GetMarketsResponse:
  """
  Retrieve perpetual market metadata from the indexer. When `market` is provided, the request filters to a single market.

  - `market`: Specific market ticker to retrieve, for example `BTC-USD`.
  - `limit`: Maximum number of market entries to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-markets)
  """
  params: dict[str, object] = {}
  if market is not None:
    params['market'] = market
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', '/v4/perpetualMarkets', params=params)
  return parse_response(r, validate=self.validate(validate))

get_market

Retrieves a single perpetual market by ticker.

Source code in pkg/src/dydx/indexer/data/get_market.py
async def get_market(
  self,
  market: str,
  *,
  validate: bool | None = None,
) -> PerpetualMarket:
  """Retrieves a single perpetual market by ticker."""
  response = await self.get_markets(market=market, limit=1, validate=validate)
  return response['markets'][market] if 'markets' in response else response[market]

get_order_book

Retrieve the orderbook for a perpetual market.

  • market: Perpetual market ticker.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_order_book.py
async def get_order_book(
  self,
  market: str,
  validate: bool | None = None
) -> OrderBook:
  """
  Retrieve the orderbook for a perpetual market.

  - `market`: Perpetual market ticker.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-perpetual-market-orderbook)
  """
  r = await self.request('GET', f'/v4/orderbooks/perpetualMarket/{market}')
  return parse_response(r, validate=self.validate(validate))

get_trades

Retrieve trades for a perpetual market.

  • market: Perpetual market ticker.
  • starting_before_or_at_height: Latest block height to include.
  • limit: Maximum number of trades to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_trades.py
async def get_trades(
  self,
  market: str,
  *,
  starting_before_or_at_height: int | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> TradesResponse:
  """
  Retrieve trades for a perpetual market.

  - `market`: Perpetual market ticker.
  - `starting_before_or_at_height`: Latest block height to include.
  - `limit`: Maximum number of trades to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-trades)
  """
  params: dict[str, object] = {}
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/trades/perpetualMarket/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

get_candles

Retrieve candle data for a perpetual market.

  • market: Perpetual market ticker.
  • resolution: Candle resolution.
  • from_iso: Start timestamp in ISO 8601 format.
  • to_iso: End timestamp in ISO 8601 format.
  • limit: Maximum number of candles to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_candles.py
async def get_candles(
  self,
  market: str,
  *,
  resolution: Literal[
    '1MIN', '5MINS', '15MINS', '30MINS', '1HOUR', '4HOURS', '1DAY'
  ],
  from_iso: datetime | None = None,
  to_iso: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> CandlesResponse:
  """
  Retrieve candle data for a perpetual market.

  - `market`: Perpetual market ticker.
  - `resolution`: Candle resolution.
  - `from_iso`: Start timestamp in ISO 8601 format.
  - `to_iso`: End timestamp in ISO 8601 format.
  - `limit`: Maximum number of candles to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-candles)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  if from_iso is not None:
    params['fromISO'] = ts.dump(from_iso)
  if to_iso is not None:
    params['toISO'] = ts.dump(to_iso)
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/candles/perpetualMarkets/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

get_candles_paged

Retrieves candle data for a specific perpetual market, paging as needed.

  • market: The market ticker (e.g. 'BTC-USD').
  • resolution: The resolution of the candles.
  • start: If given, fetches candles starting from the given timestamp.
  • end: If given, fetches candles up to and including the given timestamp.
  • limit: The max. number of candles to retrieve per request (default: 1000, max: 1000).
Source code in pkg/src/dydx/indexer/data/get_candles_paged.py
async def get_candles_paged(
  self,
  market: str,
  resolution: Resolution,
  *,
  start: datetime | None = None,
  end: datetime | None = None,
  limit: int | None = None,
) -> AsyncIterable[Sequence[Candle]]:
  """Retrieves candle data for a specific perpetual market, paging as needed.

  - `market`: The market ticker (e.g. `'BTC-USD'`).
  - `resolution`: The resolution of the candles.
  - `start`: If given, fetches candles starting from the given timestamp.
  - `end`: If given, fetches candles up to and including the given timestamp.
  - `limit`: The max. number of candles to retrieve per request (default: 1000, max: 1000).
  """
  last_time = end
  while True:
    response = await self.get_candles(
      market,
      resolution=resolution,
      from_iso=start,
      to_iso=last_time,
      limit=limit,
    )
    candles = response['candles']
    if not candles:
      break
    yield candles
    last_time = candles[-1]['startedAt']

get_historical_funding

Retrieve historical funding data for a perpetual market.

  • market: Perpetual market ticker.
  • effective_before_or_at: Latest effective timestamp to include.
  • effective_before_or_at_height: Latest effective block height to include.
  • limit: Maximum number of funding entries to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_historical_funding.py
async def get_historical_funding(
  self,
  market: str,
  *,
  effective_before_or_at: datetime | None = None,
  effective_before_or_at_height: int | None = None,
  limit: int | None = None,
  validate: bool | None = None
) -> HistoricalFundingResponse:
  """
  Retrieve historical funding data for a perpetual market.

  - `market`: Perpetual market ticker.
  - `effective_before_or_at`: Latest effective timestamp to include.
  - `effective_before_or_at_height`: Latest effective block height to include.
  - `limit`: Maximum number of funding entries to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-historical-funding)
  """
  params: dict[str, object] = {}
  if effective_before_or_at is not None:
    params['effectiveBeforeOrAt'] = ts.dump(effective_before_or_at)
  if effective_before_or_at_height is not None:
    params['effectiveBeforeOrAtHeight'] = effective_before_or_at_height
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/historicalFunding/{market}', params=params)
  return parse_response(r, validate=self.validate(validate))

get_historical_funding_paged

Retrieves historical funding rates for a specific perpetual market, automatically paginating.

  • market: The market ticker (e.g. 'BTC-USD').
  • effective_before_or_at: If given, fetches funding rates up to and including the given timestamp.
  • effective_before_or_at_height: If given, fetches funding rates up to and including the given block height.
  • limit: The max. number of candles to retrieve (default: 1000, max: 1000).
Source code in pkg/src/dydx/indexer/data/get_historical_funding_paged.py
def get_historical_funding_paged(
  self,
  market: str,
  *,
  effective_before_or_at: datetime | None = None,
  effective_before_or_at_height: int | None = None,
  limit: int | None = None,
) -> PaginatedResponse[Funding, int]:
  """Retrieves historical funding rates for a specific perpetual market, automatically paginating.

  - `market`: The market ticker (e.g. `'BTC-USD'`).
  - `effective_before_or_at`: If given, fetches funding rates up to and including the given timestamp.
  - `effective_before_or_at_height`: If given, fetches funding rates up to and including the given block height.
  - `limit`: The max. number of candles to retrieve (default: 1000, max: 1000).
  """
  last_block = effective_before_or_at_height or -1
  async def next(last_block: int | None) -> tuple[list[Funding], int | None]:
    if last_block == -1:
      last_block = None
    response = await self.get_historical_funding(
      market,
      effective_before_or_at=effective_before_or_at,
      effective_before_or_at_height=last_block,
      limit=limit,
    )
    historical_funding = response['historicalFunding']
    if not historical_funding:
      return [], None
    else:
      new_last_block = int(historical_funding[-1]['effectiveAtHeight'])
      if new_last_block == last_block:
        return [], None

    return historical_funding, new_last_block

  return PaginatedResponse(last_block, next)

get_sparklines

Get sparklines

  • time_period: Sparkline time period.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_sparklines.py
async def get_sparklines(
  self,
  *,
  time_period: Literal['OneDay', 'SevenDays'],
  validate: bool | None = None
) -> Sparkline:
  """
  Get sparklines

  - `time_period`: Sparkline time period.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/markets#get-sparklines)
  """
  params: dict[str, object] = {
    'timePeriod': time_period,
  }
  r = await self.request('GET', '/v4/sparklines', params=params)
  return parse_response(r, validate=self.validate(validate))

get_height

Get height

  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_height.py
async def get_height(
  self,
  validate: bool | None = None
) -> HeightResponse:
  """
  Get height

  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-height)
  """
  r = await self.request('GET', '/v4/height')
  return parse_response(r, validate=self.validate(validate))

get_time

Get time

  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_time.py
async def get_time(
  self,
  validate: bool | None = None
) -> TimeResponse:
  """
  Get time

  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-time)
  """
  r = await self.request('GET', '/v4/time')
  return parse_response(r, validate=self.validate(validate))

get_screen

Get screen

  • address: Wallet address to screen.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_screen.py
async def get_screen(
  self,
  address: str,
  *,
  validate: bool | None = None
) -> ComplianceResponse:
  """
  Get screen

  - `address`: Wallet address to screen.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-screen)
  """
  params: dict[str, object] = {
    'address': address,
  }
  r = await self.request('GET', '/v4/screen', params=params)
  return parse_response(r, validate=self.validate(validate))

get_compliance_screen

Get compliance screen

  • address: EVM or dYdX address.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_compliance_screen.py
async def get_compliance_screen(
  self,
  address: str,
  validate: bool | None = None
) -> ComplianceV2Response:
  """
  Get compliance screen

  - `address`: EVM or dYdX address.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/utility#get-compliance-screen)
  """
  r = await self.request('GET', f'/v4/compliance/screen/{address}')
  return parse_response(r, validate=self.validate(validate))

Account Methods

get_subaccount

Retrieve a single subaccount.

  • address: Account address.
  • subaccount: Subaccount number.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_subaccount.py
async def get_subaccount(
  self,
  address: str,
  subaccount: int,
  validate: bool | None = None
) -> GetSubaccountResponse:
  """
  Retrieve a single subaccount.

  - `address`: Account address.
  - `subaccount`: Subaccount number.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccount)
  """
  r = await self.request('GET', f'/v4/addresses/{address}/subaccountNumber/{subaccount}')
  return parse_response(r, validate=self.validate(validate))

get_subaccounts

Retrieve subaccounts for an address.

  • address: Account address.
  • limit: Maximum number of subaccounts to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_subaccounts.py
async def get_subaccounts(
  self,
  address: str,
  *,
  limit: int | None = None,
  validate: bool | None = None
) -> AddressResponse:
  """
  Retrieve subaccounts for an address.

  - `address`: Account address.
  - `limit`: Maximum number of subaccounts to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-subaccounts)
  """
  params: dict[str, object] = {}
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', f'/v4/addresses/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

get_asset_positions

Get asset positions

  • address: Wallet address that owns the account.
  • subaccount: Subaccount number.
  • status: Position status filter.
  • limit: Maximum number of results to return.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Restrict results to entries created at or before a specific timestamp.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_asset_positions.py
async def get_asset_positions(
  self,
  address: str,
  *,
  subaccount: int,
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> list[AssetPosition]:
  """
  Get asset positions

  - `address`: Wallet address that owns the account.
  - `subaccount`: Subaccount number.
  - `status`: Position status filter.
  - `limit`: Maximum number of results to return.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Restrict results to entries created at or before a specific timestamp.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-asset-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if status is not None:
    params['status'] = status
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/assetPositions', params=params)
  return parse_response(r, validate=self.validate(validate))

get_fills

Retrieve fill records for a subaccount.

  • address: Wallet address that owns the subaccount.
  • subaccount: Subaccount number.
  • market: Market ticker filter.
  • market_type: Market type filter.
  • created_before_or_at_height: Latest block height to include.
  • created_before_or_at: Latest timestamp to include.
  • limit: Maximum number of fills to return.
  • page: Page number for paginated results.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_fills.py
async def get_fills(
  self,
  address: str,
  *,
  subaccount: int,
  market: str | None = None,
  market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FillsResponse:
  """
  Retrieve fill records for a subaccount.

  - `address`: Wallet address that owns the subaccount.
  - `subaccount`: Subaccount number.
  - `market`: Market ticker filter.
  - `market_type`: Market type filter.
  - `created_before_or_at_height`: Latest block height to include.
  - `created_before_or_at`: Latest timestamp to include.
  - `limit`: Maximum number of fills to return.
  - `page`: Page number for paginated results.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if market is not None:
    params['market'] = market
  if market_type is not None:
    params['marketType'] = market_type
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fills', params=params)
  return parse_response(r, validate=self.validate(validate))

get_fills_paged

Retrieves fill records for a specific subaccount on the exchange. A fill represents a trade that has been executed.

  • address: The wallet address that owns the account.
  • subaccount: The identifier for the specific subaccount within the wallet address.
  • market: The market name (e.g. 'BTC-USD').
  • market_type: The market type ('PERPETUAL' or 'SPOT'). Must be provided if market is provided.
  • created_before_or_at_height: If given, fetches fills up to and including the given block height.
  • created_before_or_at: If given, fetches fills up to and including the given timestamp.
  • limit: The max. number of fills to retrieve (default: 1000, max: 1000).
  • validate: Whether to validate the response against the expected schema.

dYdX API docs

Source code in pkg/src/dydx/indexer/data/get_fills_paged.py
def get_fills_paged(
  self, address: str, *,
  subaccount: int,
  market: str | None = None,
  market_type: MarketType | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> PaginatedResponse[Fill, int]:
  """Retrieves fill records for a specific subaccount on the exchange. A fill represents a trade that has been executed.

  - `address`: The wallet address that owns the account.
  - `subaccount`: The identifier for the specific subaccount within the wallet address.
  - `market`: The market name (e.g. `'BTC-USD'`).
  - `market_type`: The market type (`'PERPETUAL'` or `'SPOT'`). Must be provided if `market` is provided.
  - `created_before_or_at_height`: If given, fetches fills up to and including the given block height.
  - `created_before_or_at`: If given, fetches fills up to and including the given timestamp.
  - `limit`: The max. number of fills to retrieve (default: 1000, max: 1000).
  - `validate`: Whether to validate the response against the expected schema.

  > [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-fills)
  """
  async def next(page: int) -> tuple[list[Fill], int | None]:
    response = await self.get_fills(
      address,
      subaccount=subaccount,
      market=market,
      market_type=market_type,
      created_before_or_at_height=created_before_or_at_height,
      created_before_or_at=created_before_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    fills = response['fills']
    next_page = page + 1 if len(fills) == limit else None
    return fills, next_page

  return PaginatedResponse(1, next)

get_funding_payments

Retrieve funding payment history for a subaccount.

  • address: Wallet address that owns the subaccount.
  • subaccount: Subaccount number.
  • ticker: Market ticker filter.
  • after_or_at: Earliest timestamp to include.
  • limit: Maximum number of funding payments to return.
  • page: Page number for paginated results.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_funding_payments.py
async def get_funding_payments(
  self,
  address: str,
  *,
  subaccount: int,
  ticker: str | None = None,
  after_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FundingPaymentsResponse:
  """
  Retrieve funding payment history for a subaccount.

  - `address`: Wallet address that owns the subaccount.
  - `subaccount`: Subaccount number.
  - `ticker`: Market ticker filter.
  - `after_or_at`: Earliest timestamp to include.
  - `limit`: Maximum number of funding payments to return.
  - `page`: Page number for paginated results.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if ticker is not None:
    params['ticker'] = ticker
  if after_or_at is not None:
    params['afterOrAt'] = ts.dump(after_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fundingPayments', params=params)
  return parse_response(r, validate=self.validate(validate))

get_funding_payments_paged

Retrieves funding payment history for a specific subaccount. Funding payments are periodic settlements that occur between long and short positions based on the funding rate.

  • address: The wallet address that owns the account.
  • subaccount: The identifier for the specific subaccount within the wallet address.
  • ticker: The market ticker (e.g. 'BTC-USD').
  • after_or_at: If given, fetches funding payments starting from the given timestamp.
  • limit: The max. number of funding payments to retrieve.
  • validate: Whether to validate the response against the expected schema.

dYdX API docs

Source code in pkg/src/dydx/indexer/data/get_funding_payments_paged.py
def get_funding_payments_paged(
  self,
  address: str,
  *,
  subaccount: int,
  ticker: str | None = None,
  after_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> PaginatedResponse[FundingPayment, int]:
  """Retrieves funding payment history for a specific subaccount. Funding payments are periodic settlements that occur between long and short positions based on the funding rate.

  - `address`: The wallet address that owns the account.
  - `subaccount`: The identifier for the specific subaccount within the wallet address.
  - `ticker`: The market ticker (e.g. `'BTC-USD'`).
  - `after_or_at`: If given, fetches funding payments starting from the given timestamp.
  - `limit`: The max. number of funding payments to retrieve.
  - `validate`: Whether to validate the response against the expected schema.

  > [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-funding-payments)
  """
  async def next(page: int) -> tuple[list[FundingPayment], int | None]:
    response = await self.get_funding_payments(
      address,
      subaccount=subaccount,
      ticker=ticker,
      after_or_at=after_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    funding_payments = response['fundingPayments']
    next_page = page + 1 if len(funding_payments) == limit else None
    return funding_payments, next_page

  return PaginatedResponse(1, next)

get_transfers

Retrieve transfer history for a subaccount.

  • address: Wallet address that owns the subaccount.
  • subaccount: Subaccount number.
  • created_before_or_at_height: Latest block height to include.
  • created_before_or_at: Latest timestamp to include.
  • limit: Maximum number of transfers to return.
  • page: Page number for paginated results.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_transfers.py
async def get_transfers(
  self,
  address: str,
  *,
  subaccount: int,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """
  Retrieve transfer history for a subaccount.

  - `address`: Wallet address that owns the subaccount.
  - `subaccount`: Subaccount number.
  - `created_before_or_at_height`: Latest block height to include.
  - `created_before_or_at`: Latest timestamp to include.
  - `limit`: Maximum number of transfers to return.
  - `page`: Page number for paginated results.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if limit is not None:
    params['limit'] = limit
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/transfers', params=params)
  return parse_response(r, validate=self.validate(validate))

get_transfers_paged

Retrieves the transfer history for a specific subaccount.

  • address: The wallet address that owns the account.
  • subaccount: The identifier for the specific subaccount within the wallet address.
  • created_before_or_at_height: If given, fetches transfers up to and including the given block height.
  • created_before_or_at: If given, fetches transfers up to and including the given timestamp.
  • limit: The max. number of transfers to retrieve (default: 1000, max: 1000).
  • validate: Whether to validate the response against the expected schema.

dYdX API docs

Source code in pkg/src/dydx/indexer/data/get_transfers_paged.py
async def get_transfers_paged(
  self,
  address: str,
  *,
  subaccount: int,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  limit: int | None = None,
  validate: bool | None = None,
) -> AsyncIterable[list[Transfer]]:
  """Retrieves the transfer history for a specific subaccount.

  - `address`: The wallet address that owns the account.
  - `subaccount`: The identifier for the specific subaccount within the wallet address.
  - `created_before_or_at_height`: If given, fetches transfers up to and including the given block height.
  - `created_before_or_at`: If given, fetches transfers up to and including the given timestamp.
  - `limit`: The max. number of transfers to retrieve (default: 1000, max: 1000).
  - `validate`: Whether to validate the response against the expected schema.

  > [dYdX API docs](https://docs.dydx.xyz/indexer-client/http#get-transfers)
  """
  page = 1
  while True:
    response = await self.get_transfers(
      address,
      subaccount=subaccount,
      created_before_or_at_height=created_before_or_at_height,
      created_before_or_at=created_before_or_at,
      limit=limit,
      page=page,
      validate=validate,
    )
    transfers = response['transfers']
    if not transfers:
      break
    yield transfers
    page += 1

get_transfers_between

Get transfers between subaccounts

  • source_address: Sender wallet address.
  • source_subaccount: Sender subaccount number.
  • recipient_address: Recipient wallet address.
  • recipient_subaccount: Recipient subaccount number.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Restrict results to entries created at or before a specific timestamp.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_transfers_between.py
async def get_transfers_between(
  self,
  source_address: str,
  *,
  source_subaccount: str,
  recipient_address: str,
  recipient_subaccount: str,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """
  Get transfers between subaccounts

  - `source_address`: Sender wallet address.
  - `source_subaccount`: Sender subaccount number.
  - `recipient_address`: Recipient wallet address.
  - `recipient_subaccount`: Recipient subaccount number.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Restrict results to entries created at or before a specific timestamp.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-transfers-between)
  """
  params: dict[str, object] = {
    'sourceAddress': source_address,
    'sourceSubaccountNumber': source_subaccount,
    'recipientAddress': recipient_address,
    'recipientSubaccountNumber': recipient_subaccount,
  }
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/transfers/between', params=params)
  return parse_response(r, validate=self.validate(validate))

list_orders

Retrieve orders for a subaccount with optional filters.

  • address: Wallet address that owns the subaccount.
  • subaccount: Subaccount number.
  • limit: Maximum number of orders to return.
  • ticker: Ticker filter.
  • side: Order side filter.
  • status: Order status filter.
  • type: Order type filter.
  • good_til_block_before_or_at: Latest good-til-block to include.
  • good_til_block_time_before_or_at: Latest good-til-block time to include.
  • return_latest_orders: Whether to return only the latest orders.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/list_orders.py
async def list_orders(
  self,
  address: str,
  *,
  subaccount: int,
  limit: int | None = None,
  ticker: str | None = None,
  side: Literal['BUY', 'SELL'] | None = None,
  status: Literal[
    'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
  ] | None = None,
  type: Literal[
    'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
  ] | None = None,
  good_til_block_before_or_at: int | None = None,
  good_til_block_time_before_or_at: datetime | None = None,
  return_latest_orders: bool | None = None,
  validate: bool | None = None
) -> list[Order]:
  """
  Retrieve orders for a subaccount with optional filters.

  - `address`: Wallet address that owns the subaccount.
  - `subaccount`: Subaccount number.
  - `limit`: Maximum number of orders to return.
  - `ticker`: Ticker filter.
  - `side`: Order side filter.
  - `status`: Order status filter.
  - `type`: Order type filter.
  - `good_til_block_before_or_at`: Latest good-til-block to include.
  - `good_til_block_time_before_or_at`: Latest good-til-block time to include.
  - `return_latest_orders`: Whether to return only the latest orders.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#list-orders)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if ticker is not None:
    params['ticker'] = ticker
  if side is not None:
    params['side'] = side
  if status is not None:
    params['status'] = status
  if type is not None:
    params['type'] = type
  if good_til_block_before_or_at is not None:
    params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
  if good_til_block_time_before_or_at is not None:
    params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
  if return_latest_orders is not None:
    params['returnLatestOrders'] = return_latest_orders
  r = await self.request('GET', '/v4/orders', params=params)
  return parse_response(r, validate=self.validate(validate))

get_order

Retrieve a single order by order id.

  • order_id: Order id.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_order.py
async def get_order(
  self,
  order_id: str,
  validate: bool | None = None
) -> Order:
  """
  Retrieve a single order by order id.

  - `order_id`: Order id.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#get-order)
  """
  r = await self.request('GET', f'/v4/orders/{order_id}')
  return parse_response(r, validate=self.validate(validate))

list_positions

Retrieve perpetual positions for a subaccount.

  • address: Wallet address that owns the subaccount.
  • subaccount: Subaccount number.
  • status: Position status filter.
  • limit: Maximum number of positions to return.
  • created_before_or_at_height: Latest block height to include.
  • created_before_or_at: Latest timestamp to include.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/list_positions.py
async def list_positions(
  self, address: str, *,
  subaccount: int,
  status: Literal['OPEN', 'CLOSED', 'LIQUIDATED'] | None = None,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> PositionsResponse:
  """
  Retrieve perpetual positions for a subaccount.

  - `address`: Wallet address that owns the subaccount.
  - `subaccount`: Subaccount number.
  - `status`: Position status filter.
  - `limit`: Maximum number of positions to return.
  - `created_before_or_at_height`: Latest block height to include.
  - `created_before_or_at`: Latest timestamp to include.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http#list-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if status is not None:
    params['status'] = status
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/perpetualPositions', params=params)
  return parse_response(r, validate=self.validate(validate))

get_open_position

Retrieves the open perpetual position for a specific subaccount.

Source code in pkg/src/dydx/indexer/data/get_open_position.py
async def get_open_position(
  self,
  address: str,
  market: str,
  *,
  subaccount: int,
  validate: bool | None = None,
) -> PerpetualPosition | None:
  """Retrieves the open perpetual position for a specific subaccount."""
  response = await self.list_positions(
    address,
    subaccount=subaccount,
    status='OPEN',
    validate=validate,
  )
  positions = response['positions']
  for position in positions:
    if position['market'] == market:
      return position
  return None

get_historical_pnl

Get historical pnl

  • address: Wallet address that owns the account.
  • subaccount: Subaccount number.
  • limit: Maximum number of results to return.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Restrict results to entries created at or before a specific timestamp.
  • created_on_or_after_height: Restrict results to entries created on or after a specific block height.
  • created_on_or_after: Restrict results to entries created on or after a specific timestamp.
  • page: Page number for paginated results.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_historical_pnl.py
async def get_historical_pnl(
  self,
  address: str,
  *,
  subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  created_on_or_after_height: int | None = None,
  created_on_or_after: datetime | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> list[PnlTick]:
  """
  Get historical pnl

  - `address`: Wallet address that owns the account.
  - `subaccount`: Subaccount number.
  - `limit`: Maximum number of results to return.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Restrict results to entries created at or before a specific timestamp.
  - `created_on_or_after_height`: Restrict results to entries created on or after a specific block height.
  - `created_on_or_after`: Restrict results to entries created on or after a specific timestamp.
  - `page`: Page number for paginated results.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-historical-pnl)
  """
  params: dict[str, object] = {
    'address': address,
    'subaccountNumber': subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if created_on_or_after_height is not None:
    params['createdOnOrAfterHeight'] = created_on_or_after_height
  if created_on_or_after is not None:
    params['createdOnOrAfter'] = ts.dump(created_on_or_after)
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/historical-pnl', params=params)
  return parse_response(r, validate=self.validate(validate))

get_rewards

Get historical block trading rewards

  • address: Wallet address that owns the account.
  • limit: Maximum number of results to return.
  • starting_before_or_at_height: Only include rewards starting at or before this block height.
  • starting_before_or_at: Only include rewards starting at or before this timestamp.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_rewards.py
async def get_rewards(
  self,
  address: str,
  *,
  limit: int | None = None,
  starting_before_or_at_height: int | None = None,
  starting_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> list[HistoricalBlockTradingReward]:
  """
  Get historical block trading rewards

  - `address`: Wallet address that owns the account.
  - `limit`: Maximum number of results to return.
  - `starting_before_or_at_height`: Only include rewards starting at or before this block height.
  - `starting_before_or_at`: Only include rewards starting at or before this timestamp.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards)
  """
  params: dict[str, object] = {}
  if limit is not None:
    params['limit'] = limit
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  if starting_before_or_at is not None:
    params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
  r = await self.request('GET', f'/v4/historicalBlockTradingRewards/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

get_rewards_aggregated

Get aggregated trading rewards

  • address: Wallet address that owns the account.
  • period: Aggregation period.
  • limit: Maximum number of results to return.
  • starting_before_or_at: Only include aggregations starting at or before this timestamp.
  • starting_before_or_at_height: Only include aggregations starting at or before this block height.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_rewards_aggregated.py
async def get_rewards_aggregated(
  self,
  address: str,
  *,
  period: Literal['DAILY', 'WEEKLY', 'MONTHLY'],
  limit: int | None = None,
  starting_before_or_at: datetime | None = None,
  starting_before_or_at_height: int | None = None,
  validate: bool | None = None
) -> list[HistoricalTradingRewardAggregation]:
  """
  Get aggregated trading rewards

  - `address`: Wallet address that owns the account.
  - `period`: Aggregation period.
  - `limit`: Maximum number of results to return.
  - `starting_before_or_at`: Only include aggregations starting at or before this timestamp.
  - `starting_before_or_at_height`: Only include aggregations starting at or before this block height.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-rewards-aggregated)
  """
  params: dict[str, object] = {
    'period': period,
  }
  if limit is not None:
    params['limit'] = limit
  if starting_before_or_at is not None:
    params['startingBeforeOrAt'] = ts.dump(starting_before_or_at)
  if starting_before_or_at_height is not None:
    params['startingBeforeOrAtHeight'] = starting_before_or_at_height
  r = await self.request('GET', f'/v4/historicalTradingRewardAggregations/{address}', params=params)
  return parse_response(r, validate=self.validate(validate))

Parent Subaccount And Vault Methods

get_parent_subaccount

Get parent subaccount

  • address: Wallet address that owns the parent subaccount.
  • parent_subaccount: Parent subaccount number.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_parent_subaccount.py
async def get_parent_subaccount(
  self,
  address: str,
  parent_subaccount: int,
  validate: bool | None = None
) -> ParentSubaccount:
  """
  Get parent subaccount

  - `address`: Wallet address that owns the parent subaccount.
  - `parent_subaccount`: Parent subaccount number.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-subaccount)
  """
  r = await self.request('GET', f'/v4/addresses/{address}/parentSubaccountNumber/{parent_subaccount}')
  return parse_response(r, validate=self.validate(validate))

get_parent_asset_positions

Get parent asset positions

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_parent_asset_positions.py
async def get_parent_asset_positions(
  self,
  address: str,
  *,
  parent_subaccount: int,
  validate: bool | None = None
) -> list[AssetPosition]:
  """
  Get parent asset positions

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-asset-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  r = await self.request('GET', '/v4/assetPositions/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

get_parent_fills

Get parent fills

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Latest timestamp to include.
  • market: Ticker filter.
  • market_type: Market type filter.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_parent_fills.py
async def get_parent_fills(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  market: str | None = None,
  market_type: Literal['PERPETUAL', 'SPOT'] | None = None,
  validate: bool | None = None
) -> FillsResponse:
  """
  Get parent fills

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Latest timestamp to include.
  - `market`: Ticker filter.
  - `market_type`: Market type filter.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-fills)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if market is not None:
    params['market'] = market
  if market_type is not None:
    params['marketType'] = market_type
  r = await self.request('GET', '/v4/fills/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

get_parent_historical_pnl

Get parent historical pnl

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Restrict results to entries created at or before a specific timestamp.
  • created_on_or_after_height: Restrict results to entries created on or after a specific block height.
  • created_on_or_after: Restrict results to entries created on or after a specific timestamp.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_parent_historical_pnl.py
async def get_parent_historical_pnl(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  created_on_or_after_height: int | None = None,
  created_on_or_after: datetime | None = None,
  validate: bool | None = None
) -> list[PnlTick]:
  """
  Get parent historical pnl

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Restrict results to entries created at or before a specific timestamp.
  - `created_on_or_after_height`: Restrict results to entries created on or after a specific block height.
  - `created_on_or_after`: Restrict results to entries created on or after a specific timestamp.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-historical-pnl)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  if created_on_or_after_height is not None:
    params['createdOnOrAfterHeight'] = created_on_or_after_height
  if created_on_or_after is not None:
    params['createdOnOrAfter'] = ts.dump(created_on_or_after)
  r = await self.request('GET', '/v4/historical-pnl/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

get_parent_transfers

Get parent transfers

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • created_before_or_at_height: Restrict results to entries created at or before a specific block height.
  • created_before_or_at: Restrict results to entries created at or before a specific timestamp.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_parent_transfers.py
async def get_parent_transfers(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  created_before_or_at_height: int | None = None,
  created_before_or_at: datetime | None = None,
  validate: bool | None = None
) -> TransfersResponse:
  """
  Get parent transfers

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `created_before_or_at_height`: Restrict results to entries created at or before a specific block height.
  - `created_before_or_at`: Restrict results to entries created at or before a specific timestamp.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-parent-transfers)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if created_before_or_at_height is not None:
    params['createdBeforeOrAtHeight'] = created_before_or_at_height
  if created_before_or_at is not None:
    params['createdBeforeOrAt'] = ts.dump(created_before_or_at)
  r = await self.request('GET', '/v4/transfers/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

get_funding_payments_for_parent_subaccount

Get funding payments for parent subaccount

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • after_or_at: Only include payments created at or after this timestamp.
  • page: Page number for paginated results.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_funding_payments_for_parent_subaccount.py
async def get_funding_payments_for_parent_subaccount(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  after_or_at: datetime | None = None,
  page: int | None = None,
  validate: bool | None = None
) -> FundingPaymentsResponse:
  """
  Get funding payments for parent subaccount

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `after_or_at`: Only include payments created at or after this timestamp.
  - `page`: Page number for paginated results.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#get-funding-payments-for-parent-subaccount)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if after_or_at is not None:
    params['afterOrAt'] = ts.dump(after_or_at)
  if page is not None:
    params['page'] = page
  r = await self.request('GET', '/v4/fundingPayments/parentSubaccount', params=params)
  return parse_response(r, validate=self.validate(validate))

list_parent_orders

List parent orders

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • ticker: Ticker filter.
  • side: Order side filter.
  • status: Order status filter.
  • type: Order type filter.
  • good_til_block_before_or_at: Latest good-til-block to include.
  • good_til_block_time_before_or_at: Latest good-til-block time to include.
  • return_latest_orders: Whether to return only the latest orders.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/list_parent_orders.py
async def list_parent_orders(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  ticker: str | None = None,
  side: Literal['BUY', 'SELL'] | None = None,
  status: Literal[
    'OPEN', 'FILLED', 'CANCELED', 'BEST_EFFORT_CANCELED', 'UNTRIGGERED', 'BEST_EFFORT_OPENED', 'PENDING'
  ] | None = None,
  type: Literal[
    'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP_MARKET', 'TRAILING_STOP', 'TAKE_PROFIT', 'TAKE_PROFIT_MARKET', 'HARD_TRADE', 'FAILED_HARD_TRADE', 'TRANSFER_PLACEHOLDER'
  ] | None = None,
  good_til_block_before_or_at: int | None = None,
  good_til_block_time_before_or_at: datetime | None = None,
  return_latest_orders: bool | None = None,
  validate: bool | None = None
) -> list[Order]:
  """
  List parent orders

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `ticker`: Ticker filter.
  - `side`: Order side filter.
  - `status`: Order status filter.
  - `type`: Order type filter.
  - `good_til_block_before_or_at`: Latest good-til-block to include.
  - `good_til_block_time_before_or_at`: Latest good-til-block time to include.
  - `return_latest_orders`: Whether to return only the latest orders.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-orders)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  if ticker is not None:
    params['ticker'] = ticker
  if side is not None:
    params['side'] = side
  if status is not None:
    params['status'] = status
  if type is not None:
    params['type'] = type
  if good_til_block_before_or_at is not None:
    params['goodTilBlockBeforeOrAt'] = good_til_block_before_or_at
  if good_til_block_time_before_or_at is not None:
    params['goodTilBlockTimeBeforeOrAt'] = ts.dump(good_til_block_time_before_or_at)
  if return_latest_orders is not None:
    params['returnLatestOrders'] = return_latest_orders
  r = await self.request('GET', '/v4/orders/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

list_parent_positions

List parent positions

  • address: Wallet address that owns the account.
  • parent_subaccount: Parent subaccount number.
  • limit: Maximum number of results to return.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/list_parent_positions.py
async def list_parent_positions(
  self,
  address: str,
  *,
  parent_subaccount: int,
  limit: int | None = None,
  validate: bool | None = None
) -> list[PerpetualPosition]:
  """
  List parent positions

  - `address`: Wallet address that owns the account.
  - `parent_subaccount`: Parent subaccount number.
  - `limit`: Maximum number of results to return.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/accounts#list-parent-positions)
  """
  params: dict[str, object] = {
    'address': address,
    'parentSubaccountNumber': parent_subaccount,
  }
  if limit is not None:
    params['limit'] = limit
  r = await self.request('GET', '/v4/perpetualPositions/parentSubaccountNumber', params=params)
  return parse_response(r, validate=self.validate(validate))

get_megavault_historical_pnl

Get megavault historical pnl

  • resolution: PnL tick resolution.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_megavault_historical_pnl.py
async def get_megavault_historical_pnl(
  self,
  *,
  resolution: Literal['hour', 'day'],
  validate: bool | None = None
) -> list[PnlTick]:
  """
  Get megavault historical pnl

  - `resolution`: PnL tick resolution.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-megavault-historical-pnl)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  r = await self.request('GET', '/v4/vault/v1/megavault/historicalPnl', params=params)
  return parse_response(r, validate=self.validate(validate))

get_vaults_historical_pnl

Get vaults historical pnl

  • resolution: PnL tick resolution.
  • validate: Whether to validate the response against the generated schema.

Official API docs

Source code in pkg/src/dydx/indexer/data/api/get_vaults_historical_pnl.py
async def get_vaults_historical_pnl(
  self,
  *,
  resolution: Literal['hour', 'day'],
  validate: bool | None = None
) -> list[VaultHistoricalPnl]:
  """
  Get vaults historical pnl

  - `resolution`: PnL tick resolution.
  - `validate`: Whether to validate the response against the generated schema.

  > [Official API docs](https://docs.dydx.xyz/indexer-client/http/vaults#get-vaults-historical-pnl)
  """
  params: dict[str, object] = {
    'resolution': resolution,
  }
  r = await self.request('GET', '/v4/vault/v1/vaults/historicalPnl', params=params)
  return parse_response(r, validate=self.validate(validate))