Home / Market / go-dydx-indexer

go-dydx-indexer

Unofficial Go client for the dYdX v4 Indexer HTTP API, generated with oapi-codegen. `dydxindexer.NewClientWithResponses(baseURL)` from `github.com/psyb0t/go-dydx-indexer` gives a typed method for every endpoint in the indexer's OpenAPI spec (block height and time, perpetual markets, orderbooks, candles, trades, historical funding, sparklines, subaccounts, positions, orders, fills, transfers, PnL, rewards, affiliates, vaults, compliance screening), with decoded `JSON200` response fields. The API

skill★ 00 dlclawhubMIT-0Install in CosmosUpstream Source

Documentation & Preview

go-dydx-indexer: setup and reference

Requirements

Install

go get github.com/psyb0t/go-dydx-indexer

The package name is dydxindexer. The module path ends in go-dydx-indexer, so import it with an explicit name:

import dydxindexer "github.com/psyb0t/go-dydx-indexer"

Base URLs

The paths in the spec start after /v4, so the base URL includes it:

| Network | Base URL | |---|---| | Mainnet | https://indexer.dydx.trade/v4 | | Testnet | https://indexer.v4testnet.dydx.exchange/v4 |

No auth header is needed.

Client

Operations

Typed methods are the operation ID plus WithResponse:

| Area | Operations | |---|---| | Chain | GetHeight, GetTime | | Markets | ListPerpetualMarkets, GetPerpetualMarket (orderbook for one ticker), GetCandles, GetTrades, GetHistoricalFunding, Get (sparklines) | | Addresses | GetAddress, GetSubaccount, GetParentSubaccount, RegisterToken, TestNotification | | Positions | ListPositions, ListPositionsForParentSubaccount, GetAssetPositions, GetAssetPositionsForParentSubaccount | | Orders and fills | ListOrders, ListOrdersForParentSubaccount, GetOrder, GetFills, GetFillsForParentSubaccount | | Transfers and funding | GetTransfers, GetTransfersForParentSubaccount, GetTransferBetween, GetFundingPayments, GetFundingPaymentsForParentSubaccount | | PnL and history | GetHistoricalPnl, GetHistoricalPnlForParentSubaccount, GetPnl, GetPnlForParentSubaccount, GetTradeHistory, GetTradeHistoryForParentSubaccount | | Rewards | GetTradingRewards, GetAggregations | | Affiliates | GetMetadata, GetAffiliateAddress, UpdateCode, GetSnapshot, GetTotalVolume | | Vaults | GetMegavaultHistoricalPnl, GetVaultsHistoricalPnl, GetMegavaultPositions | | Compliance and search | Screen, GetComplianceScreen, SearchTrader | | Turnkey | UploadAddress, SignIn, AppleLoginRedirect |

GetAffiliateAddress and GetComplianceScreen are renamed by make generate; the upstream spec gives them the same IDs as GetAddress and Screen.

Check the exact parameter types of a method with go doc github.com/psyb0t/go-dydx-indexer <Method> before using it.

Types

Errors

| Case | What you get | |---|---| | Network failure, bad URL, undecodable JSON | non-nil err | | 200 | JSON200 set | | Any other status | StatusCode() and raw Body, JSON200 nil |