Skip to content

Indexer Client

TODO: How to create a client instance

Rust
let indexer_client = IndexerClient::new(config);

Accounts

Rust
let accounts = indexer_client.accounts();

Get Subaccounts

Retrieves a list of subaccounts associated with a given address. Subaccounts are related addresses that fall under the authority or ownership of the primary address.

Method Declaration

Python
async def get_subaccounts(
    self,
    address: str,
    limit: Optional[int] = None,
) -> Any
Unification Plan
  • Rust implementation doesn't have optional parameters.

Parameters

ParameterLocationTypeRequiredDescription
addresspathAddresstrueThe primary address for which to retrieve associated subaccounts.

Response

StatusMeaningSchemaDescription
200OKAddressResponseThe subaccounts data.

Get Subaccount

Retrieves a specific subaccount associated with a given address and subaccount number. This method allows you to access detailed information about a single subaccount rather than retrieving all subaccounts for an address.

Method Declaration

Python
async def get_subaccount(
    self,
    address: str,
    subaccount_number: int,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe primary address to which the subaccount belongs.
subaccount_numberquerySubaccountNumbertrueThe specific subaccount number to retrieve.

Response

StatusMeaningSchemaDescription
200OKSubaccountResponseObjectThe subaccount data.

List Positions

Retrieves perpetual positions for a specific subaccount. This method allows you to query and filter the active or historical perpetual positions associated with a particular subaccount.

Method Declaration

Python
async def get_subaccount_perpetual_positions(
    self,
    address: str,
    subaccount_number: int,
    status: Optional[PositionStatus] = None,
    limit: Optional[int] = None,
    created_before_or_at_height: Optional[int] = None,
    created_before_or_at: Optional[str] = None,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
statusqueryPerpetualPositionStatusfalseFilter to retrieve positions with a specific status. If not provided, all positions will be returned regardless of status.
limitqueryu32falseMaximum number of asset positions to return in the response.
created_before_or_at_heightqueryHeightfalseRestricts results to positions created at or before a specific blockchain height.
created_before_or_atqueryDateTimefalseRestricts results to positions created at or before a specific timestamp (ISO 8601 format).

Response

StatusMeaningSchemaDescription
200OKPerpetualPositionResponseObjectThe perpetual positions data.

Get Asset Positions

Retrieves asset positions for a specific subaccount on the dYdX exchange.

This function queries the dYdX indexer API to fetch asset positions (including size, side, and other details) associated with a particular subaccount.

The endpoint being called is /v4/assetPositions.

Method Declaration

Python
async def get_subaccount_asset_positions(
    self,
    address: str,
    subaccount_number: int,
    status: Optional[PositionStatus] = None,
    limit: Optional[int] = None,
    created_before_or_at_height: Optional[int] = None,
    created_before_or_at: Optional[str] = None,
) -> Any
Unification Plan
  • Rename all methods to get_asset_positions - shorter is better.
  • Add a Subaccount pair to Python and JavaScript, since it's always a pair
  • Add options to the Rust version
  • Rename created_before_or_at_time parameter to created_before_or_at
  • Rename PerpetualPositionStatus to PositionStatus

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
statusqueryPerpetualPositionStatusfalseFilter to retrieve positions with a specific status. If not provided, all positions will be returned regardless of status.
limitqueryu32falseMaximum number of asset positions to return in the response.
created_before_or_at_heightqueryHeightfalseRestricts results to positions created at or before a specific blockchain height.
created_before_or_atqueryDateTimefalseRestricts results to positions created at or before a specific timestamp (ISO 8601 format).

Response

A data structure containing the requested asset positions. Typically includes details such as asset ID, size, side (buy/sell), entry price, realized PnL, and other position-specific information.

StatusMeaningSchemaDescription
200OKAssetPositionResponseObjectThe asset positions data.

Get Transfers

Retrieves the transfer history for a specific subaccount.

This method allows you to query and filter the transfer transactions associated with a particular subaccount.

Method Declaration

Python
async def get_subaccount_transfers(
    self,
    address: str,
    subaccount_number: int,
    limit: Optional[int] = None,
    created_before_or_at_height: Optional[int] = None,
    created_before_or_at: Optional[str] = None,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
limitqueryu32falseMaximum number of items in the response.
created_before_or_at_heightqueryHeightfalseRestricts results to positions created at or before a specific blockchain height.
created_before_or_atqueryDateTimefalseRestricts results to positions created at or before a specific timestamp.
pagequeryu32falseThe page number for paginated results.

Response

StatusMeaningSchemaDescription
200OKTransferResponseObjectThe transfers data.

List Orders

Retrieves orders for a specific subaccount, with various filtering options to narrow down the results based on order characteristics.

Method Declaration

Python
async def get_subaccount_orders(
    self,
    address: str,
    subaccount_number: int,
    ticker: Optional[str] = None,
    ticker_type: TickerType = TickerType.PERPETUAL,
    side: Optional[OrderSide] = None,
    status: Optional[OrderStatus] = None,
    type: Optional[OrderType] = None,
    limit: Optional[int] = None,
    good_til_block_before_or_at: Optional[int] = None,
    good_til_block_time_before_or_at: Optional[str] = None,
    return_latest_orders: Optional[bool] = None,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
limitqueryu32falseMaximum number of asset positions to return in the response.
tickerqueryTickerfalseThe ticker filter.
sidequeryOrderSidefalseThe order side filter.
statusqueryOrderStatusfalseThe order status filter.
typequeryOrderTypefalseThe order type filter.
good_til_block_before_or_atqueryHeightfalseThe block number filter for orders good until before or at.
good_til_block_time_before_or_atqueryDateTime in utcfalseThe timestamp filter for orders good until before or at.
return_latest_ordersqueryboolfalseWhether to return only the latest orders.

Response

StatusMeaningSchemaDescription
200OKListOrdersResponseThe orders data.

Get Order

Retrieves detailed information about a specific order based on its unique identifier.

This method allows clients to fetch the details of a particular order from the exchange by providing its order ID.

The method sends a GET request to the /v4/orders/{orderId} endpoint and returns the order data.

Method Declaration

Python
async def get_order(
    self,
    order_id: str,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
order_idpathOrderIdtrueThe order ID.

Response

StatusMeaningSchemaDescription
200OKOrderResponseObjectThe order data.

Get Fills

Retrieves fill records for a specific subaccount on the exchange.

This function queries the dYdX indexer API to fetch fill data (executed orders) associated with a particular subaccount. The endpoint being called is /v4/fills.

A fill represents a trade that has been executed on the exchange.

Method Declaration

Python
async def get_subaccount_fills(
    self,
    address: str,
    subaccount_number: int,
    ticker: Optional[str] = None,
    ticker_type: TickerType = TickerType.PERPETUAL,
    limit: Optional[int] = None,
    created_before_or_at_height: Optional[int] = None,
    created_before_or_at: Optional[str] = None,
) -> Any
Unification Plan
  • Rename all methods to get_fills - shorter is better.
  • Add a Subaccount pair to Python and JavaScript, since it's always a pair
  • Rename created_before_or_at_time parameter to created_before_or_at
  • page optional parameter is missing in Python
  • page optional parameter is missing in Rust
  • In Rust market field of the options struct must be ticker
  • In Rust market_type field of the options struct must be ticker_type

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
tickerqueryTickerfalseThe market symbol to filter fills by (e.g., "BTC-USD"). If not provided, fills for all markets will be returned.
ticker_typequeryMarketTypefalseThe type of market to filter by.
limitqueryu32falseMaximum number of asset positions to return in the response.
created_before_or_at_heightqueryHeightfalseRestricts results to positions created at or before a specific blockchain height.
created_before_or_atqueryDateTimefalseRestricts results to positions created at or before a specific timestamp (ISO 8601 format).
pagequeryu32falseThe page number for paginated results.

Response

A promise that resolves to fill data containing details such as order ID, market, side (buy/sell), size, price, execution time, and other fill-specific information.

StatusMeaningSchemaDescription
200OKFillResponseObjectThe fills data.

Get Historical Pnl

Retrieves historical profit and loss (PNL) data for a specific subaccount on the exchange.

This function queries the dYdX indexer API to fetch historical PNL records associated with a particular subaccount. The endpoint being called is '/v4/historical-pnl'.

These records provide insights into the trading performance over time.

Method Declaration

Python
async def get_subaccount_historical_pnls(
    self,
    address: str,
    subaccount_number: int,
    effective_before_or_at: Optional[str] = None,
    effective_at_or_after: Optional[str] = None,
) -> Any
Unification Plan
  • Parameter created_on_or_after_height is missing
  • Parameter created_on_or_after is missing

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
subaccount_numberquerySubaccountNumbertrueThe identifier for the specific subaccount within the wallet address.
limitqueryu32falseMaximum number of asset positions to return in the response.
created_before_or_at_heightqueryHeightfalseRestricts results to positions created at or before a specific blockchain height.
created_before_or_atquery[DateTime]falseRestricts results to positions created at or before a specific timestamp (ISO 8601 format).
created_on_or_after_heightqueryHeightfalseRestricts results to positions created on or after a specific blockchain height.
created_on_or_afterqueryDateTime in utcfalseRestricts results to positions created on or after a specific timestamp (ISO 8601 format).
pagequeryu32falseThe page number for paginated results.

Response

StatusMeaningSchemaDescription
200OKPnlTicksResponseObjectThe historical PnLs data.

Get Rewards

Retrieves historical block trading rewards for the specified address.

Method Declaration

Python
async def get_historical_block_trading_rewards(
    self,
    address: str,
    limit: Optional[int] = None,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addresspathAddresstrueThe wallet address that owns the subaccount.
limitqueryu32falseMaximum number of asset positions to return in the response.
starting_before_or_at_heightqueryHeightfalseThe timestamp filter for rewards starting before or at.
starting_before_or_atqueryDateTime in utcfalseThe block height filter for rewards starting before or at.

Response

StatusMeaningSchemaDescription
200OKHistoricalBlockTradingRewardThe historical block trading rewards data.

Get Rewards Aggregated

Retrieves aggregated historical trading rewards for the specified address.

Method Declaration

Python
async def get_historical_trading_rewards_aggregated(
    self,
    address: str,
    period: TradingRewardAggregationPeriod = TradingRewardAggregationPeriod.DAILY,
    limit: Optional[int] = None,
    starting_before_or_at: Optional[str] = None,
    starting_before_or_at_height: Optional[int] = None,
) -> Any
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addresspathAddresstrueThe wallet address that owns the subaccount.
periodqueryTradingRewardAggregationPeriodtrueThe aggregation period.
limitqueryu32falseThe maximum number of aggregated rewards to retrieve.
starting_before_or_atqueryDateTimefalseThe timestamp filter for rewards starting before or at.
starting_before_or_at_heightqueryHeightfalseThe block height filter for rewards starting before or at.

Response

StatusMeaningSchemaDescription
200OKHistoricalTradingRewardAggregationThe aggregated historical trading rewards data.

Markets

TODO: How to access to the accounts space.

Rust
let markets = indexer_client.markets();

Get Perpetual Markets

Retrieves perpetual markets.

Method Declaration

Python
def get_perpetual_markets(self, market: str = None) -> Response
Unification Plan
  • Add alias for the return type in Rust: PerpetualMarketsMap

Parameters

ParameterLocationTypeRequiredDescription
marketqueryTickerfalseThe specific market ticker to retrieve. If not provided, all markets are returned.
limitqueryu32falseMaximum number of asset positions to return in the response.

Response

StatusMeaningSchema
200OKPerpetualMarketMap

Get Perpetual Market Orderbook

Retrieves the orderbook for a specific perpetual market.

Method Declaration

Python
async def get_perpetual_market_orderbook(
    self,
    market: str,
) -> dict
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
marketpathTickertrueThe market ticker.

Response

StatusMeaningSchemaDescription
200OKOrderBookResponseObjectThe orderbook data.

Get Trades

Retrieves trades for a specific perpetual market.

Method Declaration

Python
async def get_perpetual_market_trades(
    self,
    market: str,
    starting_before_or_at_height: Optional[int] = None,
    limit: Optional[int] = None,
) -> dict
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
marketpathTickertrueThe market ticker.
limitqueryu32falseThe maximum number of trades to retrieve.
starting_before_or_at_heightqueryHeightfalseThe block height to start retrieving trades from.

Response

StatusMeaningSchemaDescription
200OKTradeResponseObjectThe trades data.

Get Candles

Retrieves candle data for a specific perpetual market.

Method Declaration

Python
async def get_perpetual_market_candles(
    self,
    market: str,
    resolution: str,
    from_iso: Optional[str] = None,
    to_iso: Optional[str] = None,
    limit: Optional[int] = None,
) -> dict
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
marketpathTickertrueThe market ticker.
resolutionqueryCandleResolutiontrueThe candle resolution (e.g., "1DAY", "1HOUR", "1MIN").
limitqueryu32falseThe maximum number of candles to retrieve.
from_isoqueryDateTimefalseThe start timestamp in ISO format.
to_isoqueryDateTimefalseThe end timestamp in ISO format.

Response

StatusMeaningSchemaDescription
200OKCandleResponseObjectThe candle data.

Get Historical Funding

Retrieves historical funding rates for a specific perpetual market.

Method Declaration

Python
async def get_perpetual_market_historical_funding(
    self,
    market: str,
    effective_before_or_at: Optional[str] = None,
    effective_before_or_at_height: Optional[int] = None,
    limit: Optional[int] = None,
) -> dict
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
marketpathTickertrueThe market ticker.
limitqueryu32falseThe maximum number of funding rates to retrieve.
effective_before_or_atquery[DateTime]falseThe timestamp to retrieve funding rates effective before or at.
effective_before_or_at_heightqueryHeightfalseThe block height to retrieve funding rates effective before or at.

Response

StatusMeaningSchemaDescription
200OKHistoricalFundingResponseObjectThe historical funding rates data.

Get Sparklines

Retrieves sparkline data for perpetual markets.

Method Declaration

Python
async def get_perpetual_market_sparklines(
    self,
    period: str = TimePeriod.ONE_DAY
) -> dict
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
periodquerySparklineTimePeriodtrueThe time period for the sparkline data (e.g., "ONE_DAY", "SEVEN_DAYS").

Response

StatusMeaningSchemaDescription
200OKSparklineResponseObjectThe sparkline data.

Utility

// TODO: Add description

Method Declaration

Get Time

Get current server time of Indexer

Method Declaration

Python
async def get_time(self) -> Dict[str, str]

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
limitqueryi32falseMaximum number of asset positions to return in the response.

Response

StatusMeaningSchema
200OKTimeResponse

Get Height

Current block height and block time (UTC) parsed by Indexer.

Method Declaration

Python
async def get_height(self) -> Dict[str, str]
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
limitquery[u32]falseMaximum number of asset positions to return in the response.

Response

StatusMeaningSchemaDescription
200OKHeightResponseDictionary containing the block height and time.

Get Screen

Query for screening results (compliance) of the address.

Method Declaration

Python
async def screen(self, address: str) -> Dict[str, bool]:
Unification Plan

Parameters

ParameterLocationTypeRequiredDescription
addressqueryAddresstrueThe wallet address that owns the subaccount.
limitqueryu32falseMaximum number of asset positions to return in the response.

Response

StatusMeaningSchema
200OKComplianceResponse