dYdX

Interact with dYdX v4 API

Overview

This node integrates with the dYdX v4 API to retrieve various types of market data related to cryptocurrency perpetual markets. It is designed to fetch detailed and specific market information such as all available markets, historical funding rates, candle (OHLC) data, market trades, market spread, and sparklines for a given market symbol.

Common scenarios where this node is beneficial include:

  • Traders or analysts who want to programmatically access up-to-date market data for algorithmic trading or portfolio analysis.
  • Developers building dashboards or alerting systems that require real-time or historical market metrics from dYdX.
  • Users needing granular candle data at different resolutions for technical analysis.

Practical examples:

  • Fetching the latest 50 trades on the BTC-USD market to analyze recent market activity.
  • Retrieving 1-hour resolution candle data for ETH-USD to plot price charts.
  • Getting historical funding rates to understand cost of holding positions over time.

Properties

Name Meaning
Market Data Type Type of market data to retrieve. Options: All Markets, Historical Funding Rates, Market Candles, Market Information, Market Sparkline, Market Spread, Market Trades
Market Market symbol (e.g., BTC-USD). Required for all market data types except "All Markets".
Candle Resolution Resolution of the candle data. Options: 1 Day, 1 Hour, 1 Minute, 15 Minutes, 30 Minutes, 4 Hours, 5 Minutes. Only applicable when Market Data Type is "Market Candles".
Limit Maximum number of results to return. Applicable for Market Trades, Market Candles, and Historical Funding Rates. Minimum value is 1. Default is 50.

Output

The node outputs JSON objects containing the requested market data along with metadata:

  • success: Boolean indicating if the request was successful.
  • data: The actual market data returned by the dYdX API. The structure varies depending on the selected Market Data Type:
    • All Markets: List of all perpetual markets available.
    • Historical Funding Rates: Array of past funding rate entries for the specified market.
    • Market Candles: OHLCV candle data at the chosen resolution.
    • Market Information: Detailed info about the specified market.
    • Market Sparkline: Sparkline data points for quick visual trend representation.
    • Market Spread: Current bid-ask spread data.
    • Market Trades: Recent trade executions for the market.
  • timestamp: ISO string timestamp of when the data was retrieved.
  • dataType: The type of market data returned (matches the selected Market Data Type).

If an error occurs and the node is set to continue on failure, the output will contain:

  • success: false
  • error: Error message describing the failure.
  • dataType: The requested market data type.

Dependencies

  • Requires an API key credential for authenticating with the dYdX v4 API.
  • Uses internal services (TradingService and AccountService) to interact with the dYdX network.
  • Network configuration and user address are obtained from the provided credentials.
  • No additional external dependencies beyond the dYdX API and n8n's credential system.

Troubleshooting

  • Common issues:

    • Missing or invalid market symbol when required will cause errors.
    • Requesting unsupported or unknown market data types will throw an error.
    • Exceeding API rate limits may result in temporary failures.
    • Incorrect or expired API credentials will prevent successful authentication.
  • Error messages:

    • "Unknown market data type: <type>": Indicates an invalid selection for Market Data Type. Verify the input property.
    • "Failed to retrieve market data: <message>": General failure fetching data; check network connectivity, API status, and credentials.
    • If the node is configured to continue on fail, errors will be reported in the output JSON under the error field without stopping execution.
  • Resolutions:

    • Ensure the Market field is filled correctly for operations requiring it.
    • Validate API credentials and regenerate if necessary.
    • Respect API usage limits and implement retries or backoff strategies externally if needed.

Links and References

Discussion