Indexer Client
TODO: How to create a client instance
let indexer_client = IndexerClient::new(config);
Accounts
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
async def get_subaccounts(
self,
address: str,
limit: Optional[int] = None,
) -> Any
Unification Plan
- Rust implementation doesn't have optional parameters.
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | path | Address | true | The primary address for which to retrieve associated subaccounts. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | AddressResponse | The 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
async def get_subaccount(
self,
address: str,
subaccount_number: int,
) -> Any
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The primary address to which the subaccount belongs. |
subaccount_number | query | SubaccountNumber | true | The specific subaccount number to retrieve. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | SubaccountResponseObject | The 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
status | query | PerpetualPositionStatus | false | Filter to retrieve positions with a specific status. If not provided, all positions will be returned regardless of status. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
created_before_or_at_height | query | Height | false | Restricts results to positions created at or before a specific blockchain height. |
created_before_or_at | query | DateTime | false | Restricts results to positions created at or before a specific timestamp (ISO 8601 format). |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | PerpetualPositionResponseObject ⛁ | The 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
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 tocreated_before_or_at
- Rename
PerpetualPositionStatus
toPositionStatus
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
status | query | PerpetualPositionStatus | false | Filter to retrieve positions with a specific status. If not provided, all positions will be returned regardless of status. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
created_before_or_at_height | query | Height | false | Restricts results to positions created at or before a specific blockchain height. |
created_before_or_at | query | DateTime | false | Restricts 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.
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | AssetPositionResponseObject ⛁ | The 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
limit | query | u32 | false | Maximum number of items in the response. |
created_before_or_at_height | query | Height | false | Restricts results to positions created at or before a specific blockchain height. |
created_before_or_at | query | DateTime | false | Restricts results to positions created at or before a specific timestamp. |
page | query | u32 | false | The page number for paginated results. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | TransferResponseObject ⛁ | The 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
ticker | query | Ticker | false | The ticker filter. |
side | query | OrderSide | false | The order side filter. |
status | query | OrderStatus | false | The order status filter. |
type | query | OrderType | false | The order type filter. |
good_til_block_before_or_at | query | Height | false | The block number filter for orders good until before or at. |
good_til_block_time_before_or_at | query | DateTime in utc | false | The timestamp filter for orders good until before or at. |
return_latest_orders | query | bool | false | Whether to return only the latest orders. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | ListOrdersResponse | The 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
async def get_order(
self,
order_id: str,
) -> Any
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
order_id | path | OrderId | true | The order ID. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | OrderResponseObject ⛁ | The 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
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 tocreated_before_or_at
page
optional parameter is missing in Pythonpage
optional parameter is missing in Rust- In Rust
market
field of the options struct must beticker
- In Rust
market_type
field of the options struct must beticker_type
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
ticker | query | Ticker | false | The market symbol to filter fills by (e.g., "BTC-USD"). If not provided, fills for all markets will be returned. |
ticker_type | query | MarketType | false | The type of market to filter by. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
created_before_or_at_height | query | Height | false | Restricts results to positions created at or before a specific blockchain height. |
created_before_or_at | query | DateTime | false | Restricts results to positions created at or before a specific timestamp (ISO 8601 format). |
page | query | u32 | false | The 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.
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | FillResponseObject ⛁ | The 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
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
subaccount_number | query | SubaccountNumber | true | The identifier for the specific subaccount within the wallet address. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
created_before_or_at_height | query | Height | false | Restricts results to positions created at or before a specific blockchain height. |
created_before_or_at | query | [DateTime] | false | Restricts results to positions created at or before a specific timestamp (ISO 8601 format). |
created_on_or_after_height | query | Height | false | Restricts results to positions created on or after a specific blockchain height. |
created_on_or_after | query | DateTime in utc | false | Restricts results to positions created on or after a specific timestamp (ISO 8601 format). |
page | query | u32 | false | The page number for paginated results. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | PnlTicksResponseObject ⛁ | The historical PnLs data. |
Get Rewards
Retrieves historical block trading rewards for the specified address.
Method Declaration
async def get_historical_block_trading_rewards(
self,
address: str,
limit: Optional[int] = None,
) -> Any
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | path | Address | true | The wallet address that owns the subaccount. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
starting_before_or_at_height | query | Height | false | The timestamp filter for rewards starting before or at. |
starting_before_or_at | query | DateTime in utc | false | The block height filter for rewards starting before or at. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | HistoricalBlockTradingReward ⛁ | The historical block trading rewards data. |
Get Rewards Aggregated
Retrieves aggregated historical trading rewards for the specified address.
Method Declaration
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | path | Address | true | The wallet address that owns the subaccount. |
period | query | TradingRewardAggregationPeriod | true | The aggregation period. |
limit | query | u32 | false | The maximum number of aggregated rewards to retrieve. |
starting_before_or_at | query | DateTime | false | The timestamp filter for rewards starting before or at. |
starting_before_or_at_height | query | Height | false | The block height filter for rewards starting before or at. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | HistoricalTradingRewardAggregation ⛁ | The aggregated historical trading rewards data. |
Markets
TODO: How to access to the accounts
space.
let markets = indexer_client.markets();
Get Perpetual Markets
Retrieves perpetual markets.
Method Declaration
def get_perpetual_markets(self, market: str = None) -> Response
Unification Plan
- Add alias for the return type in Rust:
PerpetualMarketsMap
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
market | query | Ticker | false | The specific market ticker to retrieve. If not provided, all markets are returned. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
Response
Status | Meaning | Schema |
---|---|---|
200 | OK | PerpetualMarketMap |
Get Perpetual Market Orderbook
Retrieves the orderbook for a specific perpetual market.
Method Declaration
async def get_perpetual_market_orderbook(
self,
market: str,
) -> dict
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
market | path | Ticker | true | The market ticker. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | OrderBookResponseObject ⛁ | The orderbook data. |
Get Trades
Retrieves trades for a specific perpetual market.
Method Declaration
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
market | path | Ticker | true | The market ticker. |
limit | query | u32 | false | The maximum number of trades to retrieve. |
starting_before_or_at_height | query | Height | false | The block height to start retrieving trades from. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | TradeResponseObject ⛁ | The trades data. |
Get Candles
Retrieves candle data for a specific perpetual market.
Method Declaration
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
market | path | Ticker | true | The market ticker. |
resolution | query | CandleResolution | true | The candle resolution (e.g., "1DAY", "1HOUR", "1MIN"). |
limit | query | u32 | false | The maximum number of candles to retrieve. |
from_iso | query | DateTime | false | The start timestamp in ISO format. |
to_iso | query | DateTime | false | The end timestamp in ISO format. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | CandleResponseObject ⛁ | The candle data. |
Get Historical Funding
Retrieves historical funding rates for a specific perpetual market.
Method Declaration
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
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
market | path | Ticker | true | The market ticker. |
limit | query | u32 | false | The maximum number of funding rates to retrieve. |
effective_before_or_at | query | [DateTime] | false | The timestamp to retrieve funding rates effective before or at. |
effective_before_or_at_height | query | Height | false | The block height to retrieve funding rates effective before or at. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | HistoricalFundingResponseObject ⛁ | The historical funding rates data. |
Get Sparklines
Retrieves sparkline data for perpetual markets.
Method Declaration
async def get_perpetual_market_sparklines(
self,
period: str = TimePeriod.ONE_DAY
) -> dict
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
period | query | SparklineTimePeriod | true | The time period for the sparkline data (e.g., "ONE_DAY", "SEVEN_DAYS"). |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | SparklineResponseObject ⛁ | The sparkline data. |
Utility
// TODO: Add description
Method Declaration
Get Time
Get current server time of Indexer
Method Declaration
async def get_time(self) -> Dict[str, str]
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
limit | query | i32 | false | Maximum number of asset positions to return in the response. |
Response
Status | Meaning | Schema |
---|---|---|
200 | OK | TimeResponse |
Get Height
Current block height and block time (UTC) parsed by Indexer.
Method Declaration
async def get_height(self) -> Dict[str, str]
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
limit | query | [u32] | false | Maximum number of asset positions to return in the response. |
Response
Status | Meaning | Schema | Description |
---|---|---|---|
200 | OK | HeightResponse ⛁ | Dictionary containing the block height and time. |
Get Screen
Query for screening results (compliance) of the address.
Method Declaration
async def screen(self, address: str) -> Dict[str, bool]:
Unification Plan
Parameters
Parameter | Location | Type | Required | Description |
---|---|---|---|---|
address | query | Address | true | The wallet address that owns the subaccount. |
limit | query | u32 | false | Maximum number of asset positions to return in the response. |
Response
Status | Meaning | Schema |
---|---|---|
200 | OK | ComplianceResponse ⛁ |