# 401 Client Error: Unauthorized for url:

**URL:** <https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711>\
**Category:** Alpaca Account Troubleshooting\
**Created:** [March 1, 2021, 2:15pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711 "2021-03-01T14:15:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kfmfe04](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kfmfe04/32/516_2.png) [@kfmfe04](https://forum.alpaca.markets/u/kfmfe04)\
**Post date:** [March 1, 2021, 2:15pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/1 "2021-03-01T14:15:42Z")

</div>

Using the python **alpaca-trade4-api-0.53.0** , I am getting:

`requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.polygon.io/v2/aggs/ticker/SPY/range/15/minute/2018-01-14?unadjusted=False&apiKey=XXXX`

I have a funded LIVE account that was working fine for weeks up until last Friday.  
Today is March 1, 2021. Do I need to refresh my key?

Any recommendations would be appreciated.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Clinton\_Mansfield](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/clinton_mansfield/32/277_2.png) [@Clinton\_Mansfield](https://forum.alpaca.markets/u/Clinton_Mansfield)\
**Post date:** [March 1, 2021, 2:22pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/2 "2021-03-01T14:22:14Z")

</div>

Polygon is no longer supported. The emails said you can subscribe for a free month with them. Otherwise you need to use the new Alpaca Pro API. I will say that I have not had any luck with it yet though. My account is still acting like a basic account limited to 200 calls/min

---

<div class="post-metadata">

**Author:** ![kfmfe04](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kfmfe04/32/516_2.png) [@kfmfe04](https://forum.alpaca.markets/u/kfmfe04)\
**Post date:** [March 1, 2021, 2:45pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/3 "2021-03-01T14:45:18Z")

</div>

Wow - thanks for the quick update - just found the relevant email in my gmail account.

That’s really bad news - $199/mo for real-time data is just way too much. I’ll have to look into Interactive Broker’s API and see if I can grab some intraday h1 bars from them.

Thank you.

---

<div class="post-metadata">

**Author:** ![youdar](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@youdar](https://forum.alpaca.markets/u/youdar)\
**Post date:** [March 2, 2021, 7:29am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/4 "2021-03-02T07:29:53Z")

</div>

Does anyone know of a good alternative for polygon.historic\_agg\_v2 that does not cost $200/month?

Any opinions on IEX Cloud ($10/month) ?

I would prefer to use Alpaca, but so far did not find _polygon.historic\_agg\_v2_ alternative  
I tried _get\_barset_, but it does not work well with splits, as far as I could tell

---

<div class="post-metadata">

**Author:** ![kris](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kris/32/163_2.png) [@kris](https://forum.alpaca.markets/u/kris)\
**Post date:** [March 2, 2021, 2:43pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/5 "2021-03-02T14:43:40Z")

</div>

i use finviz it doesn’t have a api but i built on over it… works the same

---

<div class="post-metadata">

**Author:** ![kfmfe04](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kfmfe04/32/516_2.png) [@kfmfe04](https://forum.alpaca.markets/u/kfmfe04)\
**Post date:** [March 2, 2021, 7:52pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/6 "2021-03-02T19:52:23Z")

</div>

For daily end-of-day bars, I use Norgate Data for $270/yr for US stocks. I essentially download the entire history/market using python and store it in one pickle file (about 1.2GB), nightly at 7 or 8PM PST. It lives in a WIndows systray and downloads prices throughout the day. The only drawback for me was having to write a python script to run within miniconda under a Windows 10 cron for scheduling. I much prefer Linux, which is not available.

As for intraday bars, I, too, am looking for an alternative. The first thing I’ll try is Interactive Broker’s API. I’ll post later if I find anything interesting.

It’s sad that Alpaca lost Polygon as that was the easiest/most direct API for intraday bars I’ve found so far.

---

<div class="post-metadata">

**Author:** ![kfmfe04](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kfmfe04/32/516_2.png) [@kfmfe04](https://forum.alpaca.markets/u/kfmfe04)\
**Post date:** [March 15, 2021, 9:07am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/7 "2021-03-15T09:07:04Z")

</div>

Update: for $14.50/mo (US Securities Snapshot for $10, US Equity and Option Add-On for $4.50) or $174/yr, Interactive Broker’s API seems to work well for trade (volume), bid, ask - there are other options I haven’t tested yet. It seems that you have to sign up for IBPro (IBLite for commission-free doesn’t allow for API access) either with fixed or tiered commissions. So, theoretically, that means better fills, but you’ll have to pay some commission.

On a daily basis, the exchanges are down 8h a day so you can grab 16h worth of h1 bars.

---

<div class="post-metadata">

**Author:** ![kris](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kris/32/163_2.png) [@kris](https://forum.alpaca.markets/u/kris)\
**Post date:** [March 15, 2021, 9:34am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/8 "2021-03-15T09:34:49Z")

</div>

just an update i use IEX now

---

<div class="post-metadata">

**Author:** ![kfmfe04](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kfmfe04/32/516_2.png) [@kfmfe04](https://forum.alpaca.markets/u/kfmfe04)\
**Post date:** [March 15, 2021, 10:00am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/9 "2021-03-15T10:00:05Z")

</div>

IEX looks very interesting - for both its free data and its exchange services.

I like their claims of transparency, but is the IEX taking the other side of every one of your trades?  
If so, there may be some conflict of interest.

---

<div class="post-metadata">

**Author:** ![kris](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kris/32/163_2.png) [@kris](https://forum.alpaca.markets/u/kris)\
**Post date:** [March 15, 2021, 10:37am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/10 "2021-03-15T10:37:11Z")

</div>

no i had to switch form relying on finviz data since i saw they were manipulating the markets

---

<div class="post-metadata">

**Author:** ![kris](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kris/32/163_2.png) [@kris](https://forum.alpaca.markets/u/kris)\
**Post date:** [March 16, 2021, 4:05pm UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/11 "2021-03-16T16:05:17Z")

</div>

just an update i use over 4 price feeds now

---

<div class="post-metadata">

**Author:** ![youdar](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@youdar](https://forum.alpaca.markets/u/youdar)\
**Post date:** [April 13, 2021, 4:11am UTC](https://forum.alpaca.markets/t/401-client-error-unauthorized-for-url/4711/12 "2021-04-13T04:11:14Z")

</div>

I ended up using the free polygon in combination with the free alpaca.

The free alpaca:

- does not consider splits
- have some random data gaps
- no before and after market pricing

The free polygon:

- very small number of API calls per minute
- consider splits
- have before and after market pricing info
- I did not experienced random data gaps
