I'm trying to pull historic data from the Coinbase Pro api using Python with the cbpro package. For some reason I either hit an error, or can only pull data from the last 350 days.

If I run the following:

import time
import cbpro
import csv
import json
import shutil
import os
start_time = time.time()
end_time = start_time-(86400*300)
public_client = cbpro.PublicClient()
data = public_client.get_product_historic_rates('ETH-USD', granularity=86400,
                                                start = start_time,
                                                end = end_time)

Then I get an "invalid interval" error. If however I remove either the "start = start_time" or "end = end_time" part of the code I get the last 350 days worth of historic data. No matter ISO 8601 time I list as "start" or "end," I'm always getting back the last 350 days starting with today.

What am I doing wrong?

1 Answer 1


The reason it was pulling data when I dropped the "start" or "end" part of the code was because the API then ignored that parameter and returned the default result.

the solution was to import the 'datetime' package and format the 'start_time" and "end_time" objects using datetime. for example:

start_time = datetime.datetime(year,month,day)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.