/Accounts pagination failing to return next page

API : Advanced API

End Point : /accounts

Documentation reference : Coinbase Cloud

Synopsis : cursor is being ignored on subsequent call to /accounts and always only returning first page of accounts.

Impact : Cannot retrieve beyond the first 49 accounts from portfolio

Details:

First response to /accounts includes set of accounts and the follow attributes :

has_next : true

cursor : “ecc7b902-8c04-589b-9519-*****519b1fd”

size : 49

Subsequent request has /accounts?cursor=ecc7b902-8c04-589b-9519-*****519b1fd

Subsequent response is exactly the same set of accounts and same cursor value as above, no next set of data available

Has it ever worked for you? For me this endpoint works, both with and without using limit parameter.

It is working in that I am getting data back but the cursor parameter is making no difference and is not changing the page of data being returned. Have you successfully been able to use this parameter?

Yes, that is why I asked if it worked in past for you. I retested also with legacy API keys, cursor works and I think it has always worked for me.

Are there any chance that there might be problem with your code/implementation? If you can, post minimal code that can be used to reproduce problem.

Have you tried to use limit parameter? Does it work?

Hi @muktupavels via Coinbase Cloud Forum

Here is as much as I can get of the raw data to make sense of it :

Initial call :

https://api.coinbase.com/api/v3/brokerage/accounts

Initial Response :

{

“accounts”: [

{

“uuid”: “0806c6f2-b400-5f1c-b1ee-580897d0b4f0”,

“name”: “PNG Wallet”,

“currency”: “PNG”,

“available_balance”: {

“value”: “4.80900398”,

“currency”: “PNG”

},

“default”: true,

“active”: true,

“created_at”: “2023-12-13T00:16:01.016Z”,

“updated_at”: “2023-12-13T11:57:59.667Z”,

“deleted_at”: null,

“type”: “ACCOUNT_TYPE_CRYPTO”,

“ready”: true,

“hold”: {

“value”: “0”,

“currency”: “PNG”

}

},

{ other 48 accounts ….},

],

“has_next”: true,

“cursor”: “ecc7b902-8c04-589b-9519-52a53519b1fd”,

“size”: 49

}

Subsequent call :

https://api.coinbase.com/api/v3/brokerage/accounts?cursor=ecc7b902-8c04-589b-9519-52a53519b1fd

Subsequent Response is exactly the same as the above response, no change

limit parameter does not seem to have any affect at any time

You still get size: 49 even if you add limit=10 parameter?

I tried a limit=300 and no effect !

Do you have an example you can share of a working cursor parameter ?

Try with something that is less than 250, documentation says maximum limit is 250.

tried with limit=10 as well be sure now, exactly the same

import http.client, hmac, hashlib, time

conn = http.client.HTTPSConnection("api.coinbase.com")
payload = ''
cb_access_key = ''
cb_access_secret = ''
timestamp = int(time.time())
path_url = f'/api/v3/brokerage/accounts?limit=2'
message = str(timestamp) + 'GET' + path_url.split('?')[0] + payload
cb_access_sign = hmac.new(cb_access_secret.encode('utf-8'), message.encode('utf-8'), digestmod=hashlib.sha256)\
                     .digest()\
                     .hex()
headers = {
  'Content-Type': 'application/json',
  'CB-ACCESS-KEY': cb_access_key,
  'CB-ACCESS-TIMESTAMP': timestamp,
  'CB-ACCESS-SIGN': cb_access_sign,
}
conn.request("GET", path_url, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

This is modified code from other topic. When I add my key and secret it does return only 2 accounts.

Do you have a working example of the cursor parameter though ?

I have no time to write code for others. Also I don’t code in python!

You told that limit also did not work for you, does it work with example code?

Sorry, I thought you had said you had working code for cursor, I’m not looking for anyone to write anything.
I have not had any working examples of either limit or cursor, in any circumstance.

Here you told that your code using limit parameter and that it is ignored (you get same response). Use posted code, add you key and secret and check if it returns only two accounts. Does it work?

My code base ic C# so I can’t directly use the posted code.
I have had the integration to Advanced Trade for a long time now, since Pro times, and all the authentication and headers are correctly in place, we have the general functionality all in place.
This is specifically a problem on this end point, we don’t generally have problems, i.e. query paramters are generalyl workign fine.

Copy code in text redactor, add your key and secret, save it as accounts.py and run it from terminal python3 accounts.py if you are on linux.

Once done that will tell you that either you have problems with your code or there are API problems. No idea if that is case but maybe you have access to other API version that might have bug while I am accessing older or newer version that works.

That was a good steer to do a rethink, thanks.
The basic python code works for both limit and cursor.
Looks like all the advanced trading api work up to now had not tested query based params, only post fields.

We had a bug where we set the httpclient without the params and only added them in after, which meant the httpclient never had the basic params at all

limit and cursor params now working correctly.

Thanks for the regular follow up.