# API not pulling historical bars

**URL:** <https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066>\
**Category:** Alpaca Market Data\
**Created:** [January 25, 2021, 10:09pm UTC](https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066 "2021-01-25T22:09:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![billsmith22](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/billsmith22/32/1695_2.png) [@billsmith22](https://forum.alpaca.markets/u/billsmith22)\
**Post date:** [January 25, 2021, 10:09pm UTC](https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066/1 "2021-01-25T22:09:28Z")

</div>

Hello,  
When I attempt to use the API, I can’t get minute data past the last 1000 minutes. I am trying to get older data. Below is my python code. Can someone help me out on this? It’s just giving me data from 1000 minutes ago up to now (when the markets are open).

```
import alpaca_trade_api as tradeapi
api = tradeapi.REST()
barset = api.get_barset('AAPL', 'minute', limit=1000 ,start="2010-04-02")
a = barset['AAPL']
print(a[0])

```

Thanks!

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [January 25, 2021, 10:54pm UTC](https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066/2 "2021-01-25T22:54:50Z")

</div>

A few issues. The `get_barset` API is quite particular about the formatting of the date. It’s a good practice to use the `isoformat()` method to do the formatting for you. If it doesn’t interpret the formatting correctly, it silently errors and uses the default date values. In this case the default is None for the start and the current date for end. So what the code above ends up like is this

barset = api.get\_barset(‘AAPL’, ‘minute’, limit=1000)

That defaults to the current day and then counts backwards 1000 minutes.

The data doesn’t go back as far as 2010 (only 2015) but that’s fine. The following will fetch all the available minute data for AAPL

```
import pandas as pd
import pytz

NY_TIMEZONE = pytz.timezone('America/New_York')
fetch_ticker = 'AAPL'

fetch_start = pd.Timestamp('2010-04-02 00:00', tz=NY_TIMEZONE).isoformat()

bardata = api.get_barset(fetch_ticker, 'minute', start=fetch_start)

```

There is a post relating to a similar issue [here](https://forum.alpaca.markets/t/get-barset-ignore-start-and-end-dates/2961/2). Good luck.

---

<div class="post-metadata">

**Author:** ![billsmith22](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/billsmith22/32/1695_2.png) [@billsmith22](https://forum.alpaca.markets/u/billsmith22)\
**Post date:** [January 25, 2021, 11:27pm UTC](https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066/3 "2021-01-25T23:27:24Z")

</div>

Thanks! I really appreciate that. This is exactly what I want!
