# 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:** 1\
**Showing post:** 2

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

---

_[View the full topic](https://forum.alpaca.markets/t/api-not-pulling-historical-bars/4066)._
