<p>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.</p>

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

<p>start_time = datetime.datetime(year,month,day)</p>

CC BY-SA 4.0
2019-02-10T07:58:03.637Z
2019-02-10T07:58:03.637Z
Victor
<p>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.</p>

<p>If I run the following:</p>

<pre><code>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()
public_client.get_product_historic_rates('ETH-USD')
data = public_client.get_product_historic_rates('ETH-USD', granularity=86400,
                                                start = start_time,
                                                end = end_time)
</code></pre>

<p>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.</p>

<p>What am I doing wrong?</p>

<api><coinbase.com>
Coinbase Pro historical data not working
Victor
# Coinbase Pro historical data not working

(Asked by: username_0 on 2019-02-10)

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()
public_client.get_product_historic_rates('ETH-USD')
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?

**Tags:** api, coinbase.com


---

## 1 answers

### Answer by username_0 on 2019-02-10. Score: 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)


---

