4 min read

🔵 Coinbase Advanced Trader Deposit and Withdrawal Automation

Introduction

In 2022, Coinbase, the largest US cryptocurrency exchange, announced that they would be sunsetting Coinbase Pro and transitioning users to their new platform, Coinbase Advanced Trader.

This change integrated the features of Coinbase Pro (formerly GDAX) natively into Coinbase.

However, to maintain functionality, users of the Coinbase Pro API need to update their code to fit within Coinbase's new /v3/ API for trading and /v2/ API for deposits and withdrawals.

In this blog post, I will share a Python script that automates deposits into and withdrawals out of your Coinbase account, which should help users who need to adapt to the new API structure.

The Code

The layer below will allow you to run all the deposit and withdrawal code in AWS (specifically we need the requests module), if you want to generate you own layer follow these instructions.

The first Python script below demonstrates how to make deposits into your Coinbase account.

This Python script contains an AWS Lambda function designed to automate deposits into Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facilitated deposit automation. The script leverages the Coinbase Wallet API to list payment methods and initiate deposits in USD. Users can customize the deposit amount and currency according to their requirements.
This Python script contains an AWS Lambda function designed to automate deposits into Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facil…
Coinbase Deposits

This next Python script demonstrates how to make withdrawals from your Coinbase account

This Python script contains an AWS Lambda function designed to automate deposits into Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facilitated withdrawal automation. The script leverages the Coinbase Wallet API to list payment methods and initiate crypto withdrawals. Users can customize the withdrawal amount and currency according to their requirements.
This Python script contains an AWS Lambda function designed to automate deposits into Coinbase accounts. It was created in response to the retirement of the Coinbase Pro API, which previously facil…
Coinbase Withdrawals

Finally, to make a connection with Coinbase and to customize your scripts you can use this config file

Sample config.json for Coinbase Withdrawals and Deposits
Sample config.json for Coinbase Withdrawals and Deposits - coinbase_config.json

Setting Up Your API Connection

Replace the placeholder values for API_KEY, API_SECRET, ACCOUNT_ID, and PAYMENT_METHOD with your Coinbase API keys and account information.

You can generate API keys by going to Coinbase.com -> Profile Picture -> Settings -> API -> New API Key.

Coinbase API Keys

Running the Deposit Script

You'll need to run the script once, calling the list_payment_methods() function.

This should return 'id' fields that you can use to populate  DEPOSIT_ID (you need the 'id' from the 'Cash (USD)' account) and PAYMENT_METHOD (in my case I used my Charles Schwab account, you would use whatever your prefered linked bank account is).

These fields can be populated in your config.json file.

Sample output of list_payment_methods() - it should show all your connected payment methods and your Coinbase fiat account (in my case USD)

Running the Withdrawal Script

Like the deposit script you'll need to run the withdrawal script once this time calling the list_accounts() function so you can populate WITHDRAWAL_ID (the internal Coinbase ID for the wallet you want to withdrawal from - this NEEDS to match the currency of the wallet you're trying to withdraw to or you could lose your funds - don't withdraw ETH to a BTC wallet address).

WITHDRAWAL_ID can also be updated in config.json.

Sample output of list_accounts() function - it should show every coin that you have a balance in (even the really small balances)

What's Next + Thanks

I received the base for this deposits code from a viewer of the YouTube channel, "TS", who wanted to remain anonymous.

Thanks to Matt Negules from Coinbase for helping me find the correct documentation and for working on updates to make developer lives easier follow him on Twitter here

Hopefuly this solution was helpful to everyone migrating over from Coinbase Pro.

Feel free to modify and expand the script according to your needs, and if you encounter any issues or have questions, please don't hesitate to reach out at rhett@rhett.blog or over on Twitter @rhettre - my DMs are open.