coinbase api client.get_accounts() 没有返回所有钱包
coinbase api client.get_accounts() not returning all wallets
目前 coinbase api 不会得到我的 atom 钱包。使用其他测试代码,我能够看到它是 return 94 个钱包,但是 none 它们是我的 atom 钱包,账户数据看起来甚至没有 94 个元素。
关于如何让我的 atom 钱包显示的任何想法?我尝试了 client.get_accounts(limit=200) 技巧但没有成功。
#import coinbase api
from coinbase.wallet.client import Client
# Coinbase Credentials
api_key = 'xxx'
api_secret = 'xxx'
# create a coinbase client
cb_client = Client(api_key, api_secret)
cb_accounts = cb_client.get_accounts()
# coin setting
coin = 'ATOM'
#print accounts
print(cb_accounts)
#get coin balance
for i in cb_accounts['data']:
if i['currency'] == coin:
coin_balance = float(i['native_balance']['amount'])
#print coin balance
print(coin_balance)
样本数据return编辑:
{
"data": [
{
"allow_deposits": true,
"allow_withdrawals": true,
"balance": {
"amount": "0.00000000",
"currency": "FET"
},
"created_at": "xxx",
"currency": "FET",
"id": "xxx",
"name": "FET Wallet",
"native_balance": {
"amount": "0.00",
"currency": "USD"
},
"primary": false,
"resource": "account",
"resource_path": "xxx",
"type": "wallet",
"updated_at": "xxx"
}
]
}
临时修复:仅启用我想通过网站上的 coinbase api 设置使用的钱包。
很烦人还是想知道是否有人能够一次取回所有钱包。
更好的方法是使用 coinbase api 分页参数:
#iniliase next wallet id
next = None
# this loop will run until the next_uri parameter is none ( it means that there is no other page to show)
while True:
accounts = client.get_accounts(starting_after=next)
next = accounts.pagination.next_starting_after
print(accounts.data)
if accounts.pagination.next_uri == None :
print("end")
break
如果你喜欢你的脚本打印你的钱包 none 零余额,试试这个:
#iniliase next wallet id
next=None
# this loop wil run until next_uri parameter is none ( it means that there is no other page to show)
while True:
accounts=client.get_accounts(starting_after=next)
next=accounts.pagination.next_starting_after
for wallet in accounts.data:
if wallet['native_balance']['amount'] != '0.00':
print(str(wallet['name']) + ' ' + str(wallet['native_balance']))
if accounts.pagination.next_uri==None :
print("end")
break
目前 coinbase api 不会得到我的 atom 钱包。使用其他测试代码,我能够看到它是 return 94 个钱包,但是 none 它们是我的 atom 钱包,账户数据看起来甚至没有 94 个元素。
关于如何让我的 atom 钱包显示的任何想法?我尝试了 client.get_accounts(limit=200) 技巧但没有成功。
#import coinbase api
from coinbase.wallet.client import Client
# Coinbase Credentials
api_key = 'xxx'
api_secret = 'xxx'
# create a coinbase client
cb_client = Client(api_key, api_secret)
cb_accounts = cb_client.get_accounts()
# coin setting
coin = 'ATOM'
#print accounts
print(cb_accounts)
#get coin balance
for i in cb_accounts['data']:
if i['currency'] == coin:
coin_balance = float(i['native_balance']['amount'])
#print coin balance
print(coin_balance)
样本数据return编辑:
{
"data": [
{
"allow_deposits": true,
"allow_withdrawals": true,
"balance": {
"amount": "0.00000000",
"currency": "FET"
},
"created_at": "xxx",
"currency": "FET",
"id": "xxx",
"name": "FET Wallet",
"native_balance": {
"amount": "0.00",
"currency": "USD"
},
"primary": false,
"resource": "account",
"resource_path": "xxx",
"type": "wallet",
"updated_at": "xxx"
}
]
}
临时修复:仅启用我想通过网站上的 coinbase api 设置使用的钱包。
很烦人还是想知道是否有人能够一次取回所有钱包。
更好的方法是使用 coinbase api 分页参数:
#iniliase next wallet id
next = None
# this loop will run until the next_uri parameter is none ( it means that there is no other page to show)
while True:
accounts = client.get_accounts(starting_after=next)
next = accounts.pagination.next_starting_after
print(accounts.data)
if accounts.pagination.next_uri == None :
print("end")
break
如果你喜欢你的脚本打印你的钱包 none 零余额,试试这个:
#iniliase next wallet id
next=None
# this loop wil run until next_uri parameter is none ( it means that there is no other page to show)
while True:
accounts=client.get_accounts(starting_after=next)
next=accounts.pagination.next_starting_after
for wallet in accounts.data:
if wallet['native_balance']['amount'] != '0.00':
print(str(wallet['name']) + ' ' + str(wallet['native_balance']))
if accounts.pagination.next_uri==None :
print("end")
break