Key Takeaways
A crypto wallet API enables programmatic wallet creation, address generation, and transaction management without building blockchain infrastructure
Cobo's WaaS 2.0 API supports 80+ blockchains with unified endpoints for all wallet types
This tutorial covers the complete flow: SDK installation, authentication, wallet creation, and sending your first transaction
Both Python and JavaScript SDKs are available with identical functionality
The development environment lets you test everything without real funds before going to production
Building crypto wallet functionality from scratch requires months of development and deep blockchain expertise. A crypto wallet API eliminates that complexity by providing ready-to-use endpoints for wallet operations.
This quickstart guide walks you through integrating a crypto wallet API in under 10 minutes. By the end, you'll have working code that creates wallets, generates deposit addresses, checks balances, and broadcasts transactions.
What is a Crypto Wallet API?
A crypto wallet API is a programmatic interface that handles blockchain wallet operations on your behalf. Instead of running nodes, managing private keys, and implementing transaction signing yourself, you make simple API calls.
Core capabilities include:
Wallet Management: Create and organize wallets programmatically
Address Generation: Generate deposit addresses for any supported blockchain
Balance Queries: Check token balances across chains in real-time
Transaction Submission: Sign and broadcast transactions to the blockchain
Webhook Notifications: Receive real-time updates on deposits and confirmations
Cobo's Wallet as a Service (WaaS) 2.0 API provides all of these capabilities with support for 80+ blockchains and 3,000+ tokens through a unified interface.
Prerequisites
Before starting, you'll need:
Cobo Account: Sign up for a free account and create an organization
API Credentials: Generate an API key and API secret from Cobo Portal
Development Environment: Python 3.7+ or Node.js 14+
Tip: Use the development environment (api.dev.cobo.com) for testing. It provides test funds and doesn't affect real assets.
Step 1: Install the SDK
Choose your preferred language and install the SDK:
Python
# Install the latest version (check GitHub for current version number)
pip install cobo-waas2
Note: For production, specify a version: pip install cobo-waas2==1.2.0. Check the GitHub repository for the latest version.
JavaScript
npm install @cobo/cobo-waas2 --save
For complete SDK documentation, visit the Cobo Developer Hub.
Step 2: Configure Authentication
Initialize the API client with your credentials. The SDK handles request signing automatically.
Python
import cobo_waas2
# Configure API client
configuration = cobo_waas2.Configuration(
# Replace with your API secret
api_private_key="<YOUR_API_SECRET>",
# Use api.dev.cobo.com for development, api.cobo.com for production
host="https://api.dev.cobo.com/v2"
)
JavaScript
const CoboWaas2 = require('@cobo/cobo-waas2');
// Initialize the API client
const apiClient = CoboWaas2.ApiClient.instance;
// Set your API secret (in hex format)
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
// Set environment: DEV for development, PROD for production
apiClient.setEnv(CoboWaas2.Env.DEV);
Security Note: Never hardcode API secrets in your code. Use environment variables or a secrets manager in production.
Step 3: Create a Wallet
Create your first custodial wallet. This wallet will hold assets and generate addresses for deposits. For enterprise use cases requiring distributed key management, consider MPC wallets instead.
Python
import cobo_waas2
from cobo_waas2 import CreateCustodialWalletParams, WalletType, WalletSubtype
configuration = cobo_waas2.Configuration(
api_private_key="<YOUR_API_SECRET>",
host="https://api.dev.cobo.com/v2"
)
# Use context manager for proper resource handling
with cobo_waas2.ApiClient(configuration) as api_client:
# Create an instance of the Wallets API
api_instance = cobo_waas2.WalletsApi(api_client)
# Define wallet parameters
create_wallet_params = cobo_waas2.CreateWalletParams(
actual_instance=CreateCustodialWalletParams(
name="My First Wallet",
wallet_type=WalletType.CUSTODIAL,
wallet_subtype=WalletSubtype.ASSET,
),
)
try:
# Create the wallet
api_response = api_instance.create_wallet(
create_wallet_params=create_wallet_params
)
print("Wallet created successfully!")
print(f"Wallet ID: {api_response.wallet_id}")
print(f"Wallet Name: {api_response.name}")
except Exception as e:
print(f"Error creating wallet: {e}")
JavaScript
const CoboWaas2 = require('@cobo/cobo-waas2');
// Initialize the API client
const apiClient = CoboWaas2.ApiClient.instance;
apiClient.setEnv(CoboWaas2.Env.DEV);
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
// Create a WalletsApi instance
const apiInstance = new CoboWaas2.WalletsApi();
// Define wallet parameters
const opts = {
CreateWalletParams: CoboWaas2.CreateWalletParams.constructFromObject({
name: "My First Wallet",
wallet_type: "Custodial",
wallet_subtype: "Asset"
})
};
// Create the wallet
apiInstance.createWallet(opts).then(
(data) => {
console.log("Wallet created successfully!");
console.log("Wallet ID:", data.wallet_id);
console.log("Wallet Name:", data.name);
},
(error) => {
console.error("Error creating wallet:", error);
}
);
Expected Response:
{
"wallet_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"wallet_type": "Custodial",
"wallet_subtype": "Asset",
"name": "My First Wallet",
"org_id": "your-org-id"
}
Step 4: Generate a Deposit Address
Generate an address to receive crypto deposits. Each address is unique and linked to your wallet.
Python
import cobo_waas2
configuration = cobo_waas2.Configuration(
api_private_key="<YOUR_API_SECRET>",
host="https://api.dev.cobo.com/v2"
)
with cobo_waas2.ApiClient(configuration) as api_client:
api_instance = cobo_waas2.WalletsApi(api_client)
wallet_id = "<YOUR_WALLET_ID>"
chain_id = "ETH" # Ethereum mainnet
try:
api_response = api_instance.create_address(
wallet_id=wallet_id,
chain_id=chain_id
)
print("Address generated successfully!")
print(f"Address: {api_response.address}")
print(f"Chain: {api_response.chain_id}")
except Exception as e:
print(f"Error generating address: {e}")
JavaScript
const CoboWaas2 = require('@cobo/cobo-waas2');
const apiClient = CoboWaas2.ApiClient.instance;
apiClient.setEnv(CoboWaas2.Env.DEV);
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
const apiInstance = new CoboWaas2.WalletsApi();
const walletId = "<YOUR_WALLET_ID>";
const opts = {
chain_id: "ETH" // Ethereum mainnet
};
apiInstance.createAddress(walletId, opts).then(
(data) => {
console.log("Address generated successfully!");
console.log("Address:", data.address);
console.log("Chain:", data.chain_id);
},
(error) => {
console.error("Error generating address:", error);
}
);
Expected Response:
{
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f...",
"chain_id": "ETH",
"wallet_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"encoding": "EVM_ADDRESS"
}
Step 5: Check Wallet Balance
Query the balance of your wallet across all tokens or for a specific asset.
Python
import cobo_waas2
configuration = cobo_waas2.Configuration(
api_private_key="<YOUR_API_SECRET>",
host="https://api.dev.cobo.com/v2"
)
with cobo_waas2.ApiClient(configuration) as api_client:
api_instance = cobo_waas2.WalletsApi(api_client)
wallet_id = "<YOUR_WALLET_ID>"
try:
api_response = api_instance.list_token_balances_for_wallet(
wallet_id=wallet_id
)
print("Wallet Balances:")
for balance in api_response.data:
print(f" {balance.token_id}: {balance.balance.total}")
except Exception as e:
print(f"Error fetching balances: {e}")
JavaScript
const CoboWaas2 = require('@cobo/cobo-waas2');
const apiClient = CoboWaas2.ApiClient.instance;
apiClient.setEnv(CoboWaas2.Env.DEV);
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
const apiInstance = new CoboWaas2.WalletsApi();
const walletId = "<YOUR_WALLET_ID>";
apiInstance.listTokenBalancesForWallet(walletId).then(
(data) => {
console.log("Wallet Balances:");
data.data.forEach(balance => {
console.log(` ${balance.token_id}: ${balance.balance.total}`);
});
},
(error) => {
console.error("Error fetching balances:", error);
}
);
Expected Response:
{
"data": [
{
"token_id": "ETH",
"balance": {
"total": "1.5",
"available": "1.5",
"pending": "0"
}
},
{
"token_id": "USDT_ETH",
"balance": {
"total": "1000.00",
"available": "1000.00",
"pending": "0"
}
}
]
}
Step 6: Send a Transaction
Broadcast a transaction to transfer tokens. The API handles signing and blockchain submission.
Python
import cobo_waas2
configuration = cobo_waas2.Configuration(
api_private_key="<YOUR_API_SECRET>",
host="https://api.dev.cobo.com/v2"
)
with cobo_waas2.ApiClient(configuration) as api_client:
api_instance = cobo_waas2.TransactionsApi(api_client)
wallet_id = "<YOUR_WALLET_ID>"
# Create transfer parameters
transfer_params = cobo_waas2.TransferParams(
request_id="unique-request-id-123", # Your unique ID for idempotency
source={
"source_type": "Asset",
"wallet_id": wallet_id
},
token_id="ETH",
destination={
"destination_type": "Address",
"account_output": {
"address": "0xRecipientAddress...",
"amount": "0.1"
}
}
)
try:
api_response = api_instance.create_transfer_transaction(
transfer_params=transfer_params
)
print("Transaction submitted!")
print(f"Transaction ID: {api_response.transaction_id}")
print(f"Status: {api_response.status}")
except Exception as e:
print(f"Error sending transaction: {e}")
JavaScript
const CoboWaas2 = require('@cobo/cobo-waas2');
const apiClient = CoboWaas2.ApiClient.instance;
apiClient.setEnv(CoboWaas2.Env.DEV);
apiClient.setPrivateKey("<YOUR_API_SECRET_IN_HEX>");
const apiInstance = new CoboWaas2.TransactionsApi();
const walletId = "<YOUR_WALLET_ID>";
const opts = {
TransferParams: CoboWaas2.TransferParams.constructFromObject({
request_id: "unique-request-id-123",
source: {
source_type: "Asset",
wallet_id: walletId
},
token_id: "ETH",
destination: {
destination_type: "Address",
account_output: {
address: "0xRecipientAddress...",
amount: "0.1"
}
}
})
};
apiInstance.createTransferTransaction(opts).then(
(data) => {
console.log("Transaction submitted!");
console.log("Transaction ID:", data.transaction_id);
console.log("Status:", data.status);
},
(error) => {
console.error("Error sending transaction:", error);
}
);
Expected Response:
{
"transaction_id": "tx_abc123def456",
"request_id": "unique-request-id-123",
"status": "Submitted",
"created_timestamp": 1699900000000
}
Step 7: Monitor with Webhooks
Set up webhooks to receive real-time notifications when transactions are confirmed or deposits arrive.
Configure your webhook endpoint in the Cobo Portal Developer Console. The API will send POST requests to your endpoint for events like:
transaction.created - New transaction initiated
transaction.success - Transaction confirmed on-chain
transaction.failed - Transaction failed
deposit.confirmed - Incoming deposit confirmed
Example Webhook Payload:
{
"event_type": "transaction.success",
"timestamp": 1699900000000,
"data": {
"transaction_id": "tx_abc123def456",
"status": "Completed",
"tx_hash": "0x123abc...",
"confirmations": 12
}
}
Common Errors and Troubleshooting
Error | Cause | Solution |
|---|
| | Check API key and secret; ensure they're registered in Cobo Portal |
| | Verify your API key has the required scopes for the operation |
| | Check required fields and parameter formats in the API documentation |
| | Implement exponential backoff; contact support for higher limits |
| | Deposit funds to your wallet before attempting transfers |
Next Steps
You've successfully integrated a crypto wallet API. Here's what to explore next:
Full API Reference: Explore all available endpoints and parameters
MPC Wallets: Set up institutional-grade wallets with distributed key management
Smart Contract Wallets: Integrate programmable wallets with advanced access controls
Transaction Policies: Configure approval workflows and spending limits
WaaS for Fintech: Learn how fintech platforms leverage wallet APIs
Ready to build? Start your 14-day free trial with full API access and dedicated support.
FAQ
How many blockchains does the crypto wallet API support?
Cobo's WaaS 2.0 API supports 80+ blockchains including Bitcoin, Ethereum, Polygon, Arbitrum, Solana, Tron, and many more. New chains are added regularly. The unified API means you use the same code patterns regardless of which blockchain you're working with.
What's the difference between development and production environments?
The development environment (api.dev.cobo.com) provides test funds and isolated wallets for safe experimentation. No real assets are at risk. The production environment (api.cobo.com) connects to live blockchains with real assets. Always test thoroughly in development before deploying to production.
How do I secure my API credentials?
Never commit API secrets to version control. Use environment variables or a secrets manager like AWS Secrets Manager or HashiCorp Vault. Rotate API keys periodically and use the minimum required permissions for each key. Enable IP allowlisting in Cobo Portal for additional security.
Can I use MPC wallets instead of custodial wallets?
Yes. Cobo supports four wallet types: Custodial, MPC (Organization-Controlled and User-Controlled), Smart Contract, and Exchange Wallets. MPC wallets provide enhanced security by distributing key shares across multiple parties. The API patterns are similar, just use the MPC-specific endpoints and parameters.