I writing convenience wrapper on top of the Coinbase API. One of the requirements is to get all user accounts.
Using proper set of scopes and after a successful OAuth authentication I can use /accounts
endpoint.
But the answer is confusing:
{
"data": [
{
"id": "xxxx-xxxx-xxxx-xxxx",
"name": "BTC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BTC",
"name": "Bitcoin",
"color": "#F7931A",
"exponent": 8,
"type": "crypto",
"sort_index": 100,
"address_regex": "^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{59}))$"
},
"balance": {
"amount": "0.03115207",
"currency": "BTC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ETC",
"name": "ETC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ETC",
"name": "Ethereum Classic",
"color": "#59D4AF",
"exponent": 8,
"type": "crypto",
"sort_index": 103,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ETC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZRX",
"name": "ZRX Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZRX",
"name": "0x",
"color": "#302C2C",
"exponent": 8,
"type": "crypto",
"sort_index": 105,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZRX"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "BAT",
"name": "BAT Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BAT",
"name": "Basic Attention Token",
"color": "#FF5000",
"exponent": 8,
"type": "crypto",
"sort_index": 106,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "BAT"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "USDC",
"name": "USDC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "USDC",
"name": "USD Coin",
"color": "#2775CA",
"exponent": 6,
"type": "crypto",
"sort_index": 107,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.000000",
"currency": "USDC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZEC",
"name": "ZEC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZEC",
"name": "Zcash",
"color": "#ECB244",
"exponent": 8,
"type": "crypto",
"sort_index": 108,
"address_regex": "^(t1|t3)[a-km-zA-HJ-NP-Z1-9]{33}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZEC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "DAI",
"name": "DAI Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "DAI",
"name": "Dai",
"color": "#FFB74D",
"exponent": 8,
"type": "crypto",
"sort_index": 115,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "DAI"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "LINK",
"name": "LINK Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "LINK",
"name": "Chainlink",
"color": "#0667D0",
"exponent": 8,
"type": "crypto",
"sort_index": 122,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "LINK"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XRP",
"name": "XRP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XRP",
"name": "XRP",
"color": "#222222",
"exponent": 6,
"type": "crypto",
"sort_index": 125,
"address_regex": "^r[1-9a-km-zA-HJ-NP-Z]{25,35}$"
},
"balance": {
"amount": "0.000000",
"currency": "XRP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "REP",
"name": "REP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "REP",
"name": "Augur",
"color": "#553580",
"exponent": 8,
"type": "crypto",
"sort_index": 126,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "REP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XLM",
"name": "XLM Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XLM",
"name": "Stellar Lumens",
"color": "#000000",
"exponent": 7,
"type": "crypto",
"sort_index": 127,
"address_regex": "^G[A-Z2-7]{55}$"
},
"balance": {
"amount": "0.0000000",
"currency": "XLM"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
}
]
The endpoint returns incomplete list of the user accounts. I have at least two more coinbase accounts
with non zero balance.
Additionally, the id are inconsistent - for BTC we have some sort of UUID in place, while other wallets are using currency code.
This makes /transactions
endpoint requests returning 404 for the requests trying to point to the different than BTC wallets:
https://api.coinbase.com/v2/accounts/EOS/transactions
.
Any idea how to get full list of accounts, plus how to work with the ID for other than BTC wallets?
The scopes I am using:
("wallet:accounts:read",
"wallet:accounts:update",
"wallet:transactions:read",
"wallet:transactions:request",
"wallet:transactions:send");
I added a transaction to one of the wallets, and it was removed from next /accounts
request, making it even more confusing.
Referencing the Coinbase Documentation https://developers.coinbase.com/docs/wallet/coinbase-connect/permissions
You can add the scope account = all
to the permission scope. This will enable read access for all coins
https://www.coinbase.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&account=all&redirect_uri=YOUR_CALLBACK_URL&scope=wallet:accounts:read,wallet:transactions:read