Coinbase Logo

Language and region

Introducing CDP Swap API: Seamless and Infra-Free Token Swaps in Minutes

June 9, 2025

By: Derek Ricciuto, Yuga Cohler, Dan Kim

TL;DR CDP Swap API lets developers quickly integrate production-ready token swaps in as little as two lines of code - no infrastructure or wallet popups needed. Swap API saves devs time by handling approvals, signing, and routing, so you can launch faster and focus on building core features for users.

No matter what you’re building onchain, sooner or later you’ll need to swap tokens - whether it’s onboarding users from fiat, rebalancing portfolios, or enabling advanced features like automated yield farming or liquidity management.

But adding swaps to your app yourself can be a headache: dealing with wallet popups, approvals, unreliable RPCs, and secure signing all slow you down and distract users from your main product.

That’s where the CDP Swap API comes in. It’s a simple, developer-friendly way to add production-grade token swaps with atomic transaction handling, backend-driven signing, and sub-500ms latency  -  all without any infrastructure setup or wallet prompts, fully integrated with the Coinbase Developer Platform. And behind the scenes, CDP Swap sources pricing from 0x, giving you access to best-effort pricing across 7M+ tokens and liquidity from 130+ exchanges -- without managing any of it yourself.

Built For Automation 

CDP Swap API is built for backend-driven, automated workflows. Unlike traditional integrations that rely on front-end wallet prompts, CDP Swap enables programmatic execution -- ideal for bots, agents, and services that need to move fast.

At the core is the account.swap() method from the CDP SDK, which lets you trigger swaps directly from your backend. It handles token approvals, transaction signing, and broadcasting in a single call. Paired with CDP Wallets -- which operate inside Coinbase’s Trusted Execution Environments (TEEs) -- this flow delivers fast, secure execution with minimal latency.

With no infrastructure to deploy, no wallet popups, and no manual approval steps, you can automate advanced flows like real-time liquidity management, portfolio rebalancing, or dynamic token allocation. The API handles quoting, signing, and routing under the hood -- so your agents focus on decision logic, not transaction plumbing.

Swap API also plays well with the full CDP stack. Use it with Coinbase Onramp for fiat-to-token onboarding, with AgentKit to let smart agents respond to onchain events, or with x402 to enable token-powered API payments. Together, CDP Swap + Wallets unlock a new class of trusted, latency-sensitive agentic flows -- like auto-reinvesting staking rewards or managing LP positions -- all programmable in just a few lines of code.

Feature

CDP Swap API

DIY Swap Integrations

Wallet integration

Native (CDP Wallets)

Must integrate EOA/MPC

Infra overhead

None

Requires RPCs, wallets

Headless swaps

Yes (account.swap())

Not supported

SLA + telemetry

Via CDP Portal

None

Monetization (if desired)

Affiliate fees built-in

Manual setup required

Support

Coinbase-backed

Community-based

What you can build

The CDP Swap API unlocks a wide range of use cases. Combined with the rest of the CDP stack, you can build fully integrated, production-grade workflows:

  • Agent-Powered Swaps: Let bots and AI agents with wallets execute token swaps programmatically, without human approval flows.

  • Fiat-to-Token Onboarding: Combine Coinbase Onramp, CDP Wallets, and Swap to let users move from fiat to your token in a single, guided flow.

  • Portfolio Tools: Build dashboards that allow users to rebalance, exit, or auto-invest in tokens directly.

  • x402 Paywalls: Use token swaps to grant access to premium APIs, features, or services  --  with no account or payment setup required.

  • Multi-Chain Deployments: Support Ethereum and Base, out of the box, with support for new networks coming soon.

How it works

All CDP Swap API requests pass through the Coinbase Developer Platform, which handles authentication, usage quotas, telemetry, and error reconciliation. This layer removes the need for custom rate-limiting or monitoring logic in your app. Liquidity is sourced from leading aggregators, abstracted behind the CDP Swap API - so developers get best-in-class pricing without managing upstream dependencies.

It also offers two flexible integration paths depending on your architecture and use case. Whether you want fully managed automation or custom wallet control, there’s an approach that fits your needs:

Approach

Features

Best For

CDP Wallet: For headless, backend-driven swaps

• Managed infrastructure • Automated signing • Built-in security • USDC rewards

Most use cases

External Library: For apps using standard EIP-1193 wallet providers like viem, wagmi, or ethers.js.

• Full control • Multiple wallet types • Custom infrastructure

Advanced needs

How to make your first swap

Getting started with the CDP Swap API is simple  --  you can go from zero to executing a token swap in just a couple of lines. No wallet popups, no token approval flows, no infrastructure setup.

Here’s a minimal example in TypeScript using the CDP SDK:

// Install the SDK

// npm install cdp-sdk

import { CdpClient } from "@coinbase/cdp-sdk";

// Initialize the CDP client

const cdp = new CdpClient();

// Retrieve an existing funded EVM account

const account = await cdp.evm.getOrCreateAccount({ name: "MyExistingFundedAccount" });

// Execute a swap: 1 WETH to USDC on Base with 1% slippage

const { transactionHash } = await account.swap({

  network: "base",

  fromToken: "0x4200000000000000000000000000000000000006", // WETH

  toToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",   // USDC

  fromAmount: BigInt("1000000000000000000"),              // 1 WETH in wei

  slippageBps: 100,

}); console.log(`Swap executed: ${transactionHash}`);

Get started

Whether you’re enabling seamless token swaps in your app, building multi-chain DeFi tools, or creating new user onboarding flows, you can integrate lightning-fast swaps in minutes -- without managing complex liquidity or smart contract infrastructure.

The CDP Swap API is built for developers who want simple, reliable, and programmable swap experiences -- designed to scale with your product. We can’t wait to see what you build.