Maximum `limit` parameter for getting product trades

Hi all,

The Get product trades API endpoint documentation (Get product trades) states that the limit parameter is type int32 and has the following limits:

However via the public API, a 400 error is raised when limit=10000 (and a quick binary suggests that limit is at 1000.

HTTPError: 400 Client Error: Bad Request for url: https://api.exchange.coinbase.com/products/BTC-USD/trades?limit=1100

Using before and after parameters doesn’t circumvent the issue too:

Epoch in milliseconds (also tried in seconds):

HTTPError: 400 Client Error: Bad Request for url: https://api.exchange.coinbase.com/products/BTC-USD/trades?after=1643081172000&before=1643082172000
  1. Is it possible to change the documentation so that it is more informative?
  2. Is the 1000 max limit correct?
  3. Is there a similar max limit for the difference between before and after parameters?
1 Like

:wave: We’re looking into this and will get back to you soon! I’ve reached out for clarity on documentation and the actual max for limit, before, and after parameters.

1 Like

@nottakumasato - Thank you for reaching out here and for bringing these questions to our attention. We definitely appreciate the feedback and are working to clean up these documents for more clarity. Additionally, I can confirm that yes, the max limit is indeed 1000. Should more information arise, I will be sure to follow up here. Thanks again!

2 Likes

@arood
@staff1

Hi, hoping you might be able to help me out. I have been trying to get product trades but the params “after” and “before” are not working as they should, instead only returning an empty list.

In python this works to pull the latest data:

res = requests.get('https://api.pro.coinbase.com/products/BTC-USD/trades')

But the following returns an empty list:

res = requests.get('https://api.pro.coinbase.com/products/BTC-USD/trades',
                                  params ={
                                           "after": 1609459200, 
                                           "before": 1615248000, 
                                  }
                  ).json()
pd.Timestamp(1609459200, unit='s') = Timestamp('2021-01-01 00:00:00')
pd.Timestamp(1609459200, unit='s') = Timestamp('2021-03-09 00:00:00')

Moreover the min parameters in the docs are wrong, if you try and provide the min value you get:

{'message': 'Invalid positive integer value for parameter - after'}

Are you able to advise me on how to specify the “before” and “after” params so I can pull historical data reliably?

@algocb - Checking on this for you! Thanks for posting

1 Like

@algocb Before and After are int page ids - Documentation info is here: Pagination

@arood Thanks for your help. I see, I did not realise this - quite unintuitive. If I want to pull data between specific timestamps do you know how I can convert this to a pagination ID?

Was just searching for the same, this new documentation does not tell you what the maximum limit for all these API calls is, while the old one few years ago said it would be 100. So at least you raised the max limit to 1000 now, which is good.

Hi @Serpens66, we’re so sorry for any inconvenience this has caused you. We are still in the process of improving and updating our documentations. We thank you for your patience and understanding.