-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
coinbase fetch all balances
github-actions[bot] edited this page Jun 11, 2026
·
2 revisions
"use strict";
const ccxt = require ('../../js/ccxt.js')
console.log ('CCXT Version:', ccxt.version)
async function fetchAllBalances (exchange) {
const params = {}
let balance = {}
while (true) {
const response = await exchange.fetchBalance (params)
balance = exchange.extend (balance, response)
const info = exchange.safeValue (response, 'info', {})
const pagination = exchange.safeValue (info, 'pagination', {})
const startingAfter = exchange.safeString (pagination, 'next_starting_after')
if (startingAfter !== undefined) {
params['starting_after'] = startingAfter
} else {
break
}
}
return balance
}
async function main () {
const exchange = new ccxt.coinbase ({
// Value is the "name" field in the api_key.json file Coinbase will offer for download
apiKey: 'organizations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apiKeys/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
// This is the "privateKey" field in that JSON file
secret: '-----BEGIN EC PRIVATE KEY-----\nxxx...xxx==\n-----END EC PRIVATE KEY-----',
})
const markets = await exchange.loadMarkets ()
// coinbase.verbose = true // uncomment for debugging purposes if necessary
const balance = await fetchAllBalances (exchange)
console.log (balance)
}
main ()(If the page is not being rendered for you, you can refer to the mirror at https://docs.ccxt.com/)
- Install
- Examples
- Manual
- CCXT Pro
- Contributing
- Supported Exchanges
- Exchanges By Country
- API Spec By Method
- FAQ
- Changelog
- Awesome
- API Spec by Exchange
- fetchCurrencies
- alpaca
- apex
- ascendex
- aster
- backpack
- bigone
- binance
- bingx
- bit2c
- bitbank
- bitbns
- bitfinex
- bitflyer
- bitget
- bithumb
- bitmart
- bitmex
- bitopro
- bitrue
- bitso
- bitstamp
- bitteam
- bittrade
- bitvavo
- blockchaincom
- blofin
- btcbox
- btcmarkets
- btcturk
- bullish
- bybit
- bydfi
- cex
- coinbase
- coinbaseexchange
- coinbaseinternational
- coincheck
- coinex
- coinmate
- coinmetro
- coinone
- coinsph
- coinspot
- cryptocom
- cryptomus
- deepcoin
- delta
- deribit
- derive
- digifinex
- dydx
- exmo
- extended
- foxbit
- gate
- gemini
- grvt
- hashkey
- hibachi
- hitbtc
- hollaex
- htx
- hyperliquid
- independentreserve
- indodax
- kraken
- krakenfutures
- kucoin
- fetchBidsAsks
- latoken
- lbank
- lighter
- luno
- mercado
- mexc
- modetrade
- ndax
- novadax
- okx
- onetrading
- p2b
- pacifica
- paradex
- paymium
- phemex
- poloniex
- tokocrypto
- toobit
- upbit
- weex
- whitebit
- woo
- woofipro
- xt
- zaif
- fetchStatus