# Help with alpaca polygon api

**URL:** <https://forum.alpaca.markets/t/help-with-alpaca-polygon-api/402>\
**Category:** Alpaca Account Troubleshooting\
**Created:** [October 29, 2019, 4:38pm UTC](https://forum.alpaca.markets/t/help-with-alpaca-polygon-api/402 "2019-10-29T16:38:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tvdevelop1](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@tvdevelop1](https://forum.alpaca.markets/u/tvdevelop1)\
**Post date:** [October 29, 2019, 4:38pm UTC](https://forum.alpaca.markets/t/help-with-alpaca-polygon-api/402/1 "2019-10-29T16:38:37Z")

</div>

## Environment

**Language**  
_Python 3.7_

**Alpaca SDK Version**  
_Latest_

**Other Environment Details**  
Using historic\_agg\_v2 polygon function to get aggregate data

## Problem

**Summary**  
_I am new to alpaca. My usage of historic\_agg\_v2 is returning a None object. Trying to get hourly, minutes, or day polygon aggregate data. I am using agg\_v2 since it return historic data for minutes, but this doesn’t seem to work with my usage. I also tried passing limit =10 and instead of ‘day’ using ‘hour’, either didn’t seem to work. Would greatly appreciate help here. Thanks_

**Paper or Live Trading?**  
_Live Trading account_

**Example Code**

````auto
ENDPOINT ='https://api.alpaca.markets'
api = alpaca.REST(KEYID, SECRETKEY, ENDPOINT)
api. api.polygon.historic_agg_v2('AAPL', 1, 'day', 2019-10-28, 2019-10-29, False)```

TypeError: 'NoneType' object is not iterable
````

---

<div class="post-metadata">

**Author:** ![Trader\_Joe](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Trader\_Joe](https://forum.alpaca.markets/u/Trader_Joe)\
**Post date:** [November 3, 2019, 6:39am UTC](https://forum.alpaca.markets/t/help-with-alpaca-polygon-api/402/2 "2019-11-03T06:39:31Z")

</div>

Looks like the dates you pass are not enclosed in quotes. Best to use a date(2019, 10, 28) format. I suggest explicitly use parameter keys \_from=…, to=… and then increment the date by 1 or 2 days to check.

I played with both v1 and v2 - both seem to work for your purpose with some quirks. In v1 call, you can call for only 1 minute or 1 day bars; in v2 you can specify multiples of these periods (eg 5 minutes, 60 minutes, 5 days). In v1 you can specify a datetime object in \_from= and to= and the time part will be taken account in filtering (for example you can request regular market hours only); in v2 you cannot filter by time, results will sweep for before and after hours.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![tvdevelop1](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@tvdevelop1](https://forum.alpaca.markets/u/tvdevelop1)\
**Post date:** [January 3, 2020, 1:19am UTC](https://forum.alpaca.markets/t/help-with-alpaca-polygon-api/402/3 "2020-01-03T01:19:50Z")

</div>

Thanks Trader\_Joe.  
I just wanted to highlight the solution that I used to get the dataframe, (has been long due!!)  
df = api.polygon.historic\_agg\_v2(‘AAPL’, 1, ‘day’, ‘2014-10-28’,str(datetime.date.today()), False,limit=10).df  
This returns a dataframe df with last 10 transactions.  
One can set any dates and time frames as Trader\_Joe mentioned in his reply.
