# dYdX trading bot setup: API keys, testnet and fees

> How to run a trading bot on dYdX: what its API keys can do, testnet, fees, rate limits and who&#x27;s restricted. Sourced from dYdX&#x27;s own docs.

Canonical: https://tradingagentstack.com/dydx-trading-bot/

1. [Home](https://tradingagentstack.com/)

2. [Perp DEXs for bots](https://tradingagentstack.com/best-perp-dex-for-trading-bots/)

3. dYdX

# dYdX trading bot setup (2026): keys, testnet, fees and limits

Order-book perps on dYdX's own Cosmos chain; validators run the order book and you hold your own keys. Here's how to run a trading bot or AI agent on it without handing it more power than it needs. Every fact links dYdX's own docs, checked Oct 30, 2026.

**Watch out:** Pin client package versions: its official npm and PyPI packages were compromised in January 2026.

| Safety score | [Safety 68%](https://tradingagentstack.com/tool/dydx/) |
| --- | --- |
| Bot key | Permissioned keys can block withdrawals [source](https://docs.dydx.xyz/concepts/trading/authenticators) |
| Testnet | Yes [source](https://docs.dydx.xyz/interaction/endpoints) |
| Base fees (maker / taker) | 0.01% / 0.05% [source](https://docs.dydx.xyz/concepts/trading/rewards) |
| Rate limits | Long-lived orders: 2 per block and 20 per 100 blocks per account; short-term orders and cancels: 4,000 per 5 blocks. Indexer: 100 requests per 10 seconds per IP. [source](https://docs.dydx.xyz/concepts/trading/limits/rate-limits) |
| Anyone can check an account's results | Yes, any address [source](https://docs.dydx.xyz/interaction/integration/integration-portfolio) |
| Restricted | US, Canada and more [source](https://docs.dydx.xyz/interaction/integration/integration-compliance) |
| Builder codes | Builder codes on any order, up to 1% of the fill, with no vote needed. [source](https://docs.dydx.xyz/interaction/integration/integration-builder-codes) |
| Referrals | Affiliate program open after $10 of volume: up to 15% of referees' taker fees (capped per referral); vetted VIP affiliates more. [source](https://www.dydx.foundation/blog/dydx-affiliate-program) |

## Set up a bot on dYdX, step by step

1. **Make sure you're on the real site.** Fake trading sites and bots copy every big exchange. Before you connect a wallet, use the official app at [dydx.trade](https://dydx.trade).

2. **Give the bot its own account.** Put the bot in a separate sub-account or wallet with only the money it needs, so a bug or a leaked key can't reach the rest.

3. **Create the bot's key.** Use a key that can trade but not send money out. Permissioned keys can be limited by action, market and sub-account, so a trading key can be barred from withdrawals and transfers. Keys can't cap order size or leverage. [docs](https://docs.dydx.xyz/concepts/trading/authenticators)

4. **Run it on testnet first.** Public testnet front end, indexer and faucet. [docs](https://docs.dydx.xyz/interaction/endpoints)

5. **Stay inside the rate limits.** Long-lived orders: 2 per block and 20 per 100 blocks per account; short-term orders and cancels: 4,000 per 5 blocks. Indexer: 100 requests per 10 seconds per IP. [docs](https://docs.dydx.xyz/concepts/trading/limits/rate-limits)

6. **Count the fees.** Tier 1: 0.01% maker, 0.05% taker; governance can change fees, so check dydx.trade. [docs](https://docs.dydx.xyz/concepts/trading/rewards)

7. **Put limits outside the bot.** A bot can't be trusted to police itself. [TAS Guard](https://tradingagentstack.com/guard/) adds order caps, phone approval and a kill switch in front of an AI agent, including Hyperliquid and EVM wallets.

8. **Let your results speak.** The keyless indexer returns any address's positions, fills, transfers and historical PnL; MegaVault's results are public. [docs](https://docs.dydx.xyz/interaction/integration/integration-portfolio) That means a bot's record can be checked by anyone. [Get your agent verified](https://tradingagentstack.com/get-your-ai-agent-verified/).

## AI agent tools

No official MCP server or agent kit; community only. [source](https://docs.dydx.xyz/repositories)

## Code and audits

Open-source chain, indexer and clients; audit reports are in the v4-chain repo. [source](https://github.com/dydxprotocol/v4-chain/tree/main/audits)

## Incidents, last 12 months

- Jan 28, 2026: Malicious versions of dYdX's npm and PyPI client packages carried wallet-stealing malware; dYdX told affected users to move funds and rotate keys. [news report](https://thehackernews.com/2026/02/compromised-dydx-npm-and-pypi-packages.html)

## FAQ

### Can I run a trading bot on dYdX?

Yes. dYdX has an API for automated trading. Permissioned keys can be limited by action, market and sub-account, so a trading key can be barred from withdrawals and transfers. Keys can't cap order size or leverage.

### Does dYdX have a testnet?

Public testnet front end, indexer and faucet.

### Can a dYdX API key withdraw my funds?

Permissioned keys can be limited by action, market and sub-account, so a trading key can be barred from withdrawals and transfers. Keys can't cap order size or leverage.

### Can US residents use dYdX?

No. dYdX's terms restrict: US and Canada plus sanctioned places, per the docs' compliance page.

### What are dYdX's trading fees for bots?

Tier 1: 0.01% maker, 0.05% taker; governance can change fees, so check dydx.trade.

## Compare

- [Hyperliquid vs dYdX for trading bots](https://tradingagentstack.com/hyperliquid-vs-dydx-for-trading-bots/)

- [All 9 perp DEXs compared for bots](https://tradingagentstack.com/best-perp-dex-for-trading-bots/)

- [dYdX Safety score and tool page](https://tradingagentstack.com/tool/dydx/)

Other exchanges: [Hyperliquid](https://tradingagentstack.com/hyperliquid-trading-bot/) · [Lighter](https://tradingagentstack.com/lighter-trading-bot/) · [Aster](https://tradingagentstack.com/aster-trading-bot/) · [GMX](https://tradingagentstack.com/gmx-trading-bot/) · [Paradex](https://tradingagentstack.com/paradex-trading-bot/) · [Extended](https://tradingagentstack.com/extended-trading-bot/) · [Pacifica](https://tradingagentstack.com/pacifica-trading-bot/) · [edgeX](https://tradingagentstack.com/edgex-trading-bot/)

Facts from dYdX's docs, terms and GitHub, read Oct 30, 2026; news reports are marked. Fees and limits change: confirm on dYdX's site. No referral links. Not financial advice.

## For agents

- [When to use this site, and the page index](https://tradingagentstack.com/llms.txt)
- [Sitemap](https://tradingagentstack.com/sitemap.xml)
- [Contact](https://tradingagentstack.com/contact/)
- [MCP server](https://tradingagentstack.com/mcp/)
- [MCP discovery](https://tradingagentstack.com/.well-known/mcp)
