CdpClient
The CdpClient class is the main entry point for interacting with the Coinbase Developer Platform API. It manages authentication, API clients, and provides access to EVM, Solana, policy, and end-user operations.
Constructor
CdpClient(
api_key_id: str | None = None,
api_key_secret: str | None = None,
wallet_secret: str | None = None,
debugging: bool = False,
base_path: str = "https://api.cdp.coinbase.com/platform",
max_network_retries: int = 3,
source: str = SDK_DEFAULT_SOURCE,
source_version: str = __version__,
)
Instantiate the CdpClient.
The API key ID. Defaults to the CDP_API_KEY_ID environment variable.
The API key secret. Defaults to the CDP_API_KEY_SECRET environment variable.
The wallet secret. Defaults to the CDP_WALLET_SECRET environment variable.
Whether to enable debugging.
base_path
str
default:"https://api.cdp.coinbase.com/platform"
The base path for API requests.
The maximum number of network retries.
If required API credentials are missing.
Properties
evm
@property
def evm(self) -> EvmClient:
Get the EvmClient instance for EVM operations.
solana
@property
def solana(self) -> SolanaClient:
Get the SolanaClient instance for Solana operations.
The Solana client instance.
policies
@property
def policies(self) -> PoliciesClient:
Get the PoliciesClient instance for policy management.
The policies client instance.
end_user
@property
def end_user(self) -> EndUserClient:
Get the EndUserClient instance for end user operations.
The end user client instance.
Methods
close
async def close(self) -> None:
Close the CDP client and release resources.
Context Manager
The CdpClient can be used as an async context manager:
async with CdpClient(
api_key_id="your-api-key-id",
api_key_secret="your-api-key-secret",
) as cdp:
# Use the client
account = await cdp.evm.create_account()
# Automatically closed when exiting the context
Example Usage
Basic Initialization
from cdp import CdpClient
# Using environment variables
cdp = CdpClient()
# Explicit credentials
cdp = CdpClient(
api_key_id="your-api-key-id",
api_key_secret="your-api-key-secret",
wallet_secret="your-wallet-secret",
)
Create an EVM Account
from cdp import CdpClient
cdp = CdpClient(
api_key_id="your-api-key-id",
api_key_secret="your-api-key-secret",
)
# Create an EVM account
account = await cdp.evm.create_account(name="My Account")
print(f"Account address: {account.address}")
# Close the client when done
await cdp.close()
Using Context Manager
from cdp import CdpClient
async with CdpClient(
api_key_id="your-api-key-id",
api_key_secret="your-api-key-secret",
) as cdp:
# Create a Solana account
account = await cdp.solana.create_account(name="My Solana Account")
print(f"Solana address: {account.address}")