# 403 Client Error: Forbidden for url

**URL:** <https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118>\
**Category:** Getting Started with Alpaca\
**Created:** [January 28, 2021, 4:21pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118 "2021-01-28T16:21:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ebel\_Magnin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/ebel_magnin/32/1929_2.png) [@Ebel\_Magnin](https://forum.alpaca.markets/u/Ebel_Magnin)\
**Post date:** [January 28, 2021, 4:21pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/1 "2021-01-28T16:21:51Z")

</div>

Hi there,

Got a 403 Client Error: Forbidden url with the below Python program:

import pandas as pd  
import alpaca\_trade\_api as tradeapi  
api = tradeapi.REST(api\_version=‘v2’)  
result = api.get\_barset(‘AAPL’, ‘minute’, start = ‘2021-01-28’, end = ‘2021-01-28’).df  
print(result)

Response: requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: [https://data.alpaca.markets/v1/bars/minute?symbols=AAPL&start=2021-01-28&end=2021-01-28](https://data.alpaca.markets/v1/bars/minute?symbols=AAPL&start=2021-01-28&end=2021-01-28)

Any idea what is causing this?

Ebel

---

<div class="post-metadata">

**Author:** ![Joel\_Neuendorf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/joel_neuendorf/32/1923_2.png) [@Joel\_Neuendorf](https://forum.alpaca.markets/u/Joel_Neuendorf)\
**Post date:** [May 27, 2021, 11:32pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/2 "2021-05-27T23:32:33Z")

</div>

I intermittently get the same thing for the following url:  
[https://paper-api.alpaca.markets/v2/orders](https://paper-api.alpaca.markets/v2/orders)

I’m also looking for ideas on what could be causing this type of error.

Joel

---

<div class="post-metadata">

**Author:** ![Kalmar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kalmar/32/3022_2.png) [@Kalmar](https://forum.alpaca.markets/u/Kalmar)\
**Post date:** [August 31, 2021, 10:14pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/3 "2021-08-31T22:14:16Z")

</div>

I also get the same error. `get_bars` or `get_barset` show the 403 error: “_Forbidden for url: [https://data.alpaca.markets](https://data.alpaca.markets)…_”  
`alpaca.get_bars("AAPL", TimeFrame.Day, "2021-08-01", "2021-08-30", limit=10, adjustment='raw')`

Somehow all other requests are working: `alpaca.list_positions()` or `alpaca.get_account()`

Is it about free plan? Pls advise.

---

<div class="post-metadata">

**Author:** ![Kalmar](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/kalmar/32/3022_2.png) [@Kalmar](https://forum.alpaca.markets/u/Kalmar)\
**Post date:** [August 31, 2021, 10:26pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/4 "2021-08-31T22:26:23Z")

</div>

Sorry for bothering. I needed to generate new paper account key. Old probably was too old.

---

<div class="post-metadata">

**Author:** ![algotrader.me](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/algotrader.me/32/6312_2.png) [@algotrader.me](https://forum.alpaca.markets/u/algotrader.me)\
**Post date:** [July 24, 2022, 4:45pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/5 "2022-07-24T16:45:28Z")

</div>

same issue, how did you resolve it.

---

<div class="post-metadata">

**Author:** ![livefire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/livefire/32/4457_2.png) [@livefire](https://forum.alpaca.markets/u/livefire)\
**Post date:** [September 1, 2022, 8:00pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/6 "2022-09-01T20:00:55Z")

</div>

I didn’t quite see the API and SECRET key being passed

api = tradeapi.REST(API\_KEY, SECRET\_KEY, BASE\_URL, api\_version=“v2”)

Base URL as “[https://paper-api.alpaca.markets](https://paper-api.alpaca.markets)”?

---

<div class="post-metadata">

**Author:** ![Mirex](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/mirex/32/4983_2.png) [@Mirex](https://forum.alpaca.markets/u/Mirex)\
**Post date:** [January 10, 2023, 12:32pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/7 "2023-01-10T12:32:21Z")

</div>

hi, how you solve it?

---

<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 13, 2023, 1:28pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/8 "2023-01-13T13:28:48Z")

</div>

@Mirex A ‘Forbidden’ error is most likely one of three things 1) the API key/secret key are old or incorrect 2) the API key/secret key/ base url don’t align (eg one is using their paper API keys but accessing the live base url or 3) for market data one only has a Free subscription but is trying to access features only available in an “Unlimited” subscription.

---

<div class="post-metadata">

**Author:** ![Artem](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/artem/32/5326_2.png) [@Artem](https://forum.alpaca.markets/u/Artem)\
**Post date:** [April 26, 2023, 6:24pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/9 "2023-04-26T18:24:09Z")

</div>

I have a GO example of a forbidden error.  
The issue that the code is not correct in the documentation:

```auto
	alpaca.PlaceOrder(alpaca.PlaceOrderRequest{
		AssetKey: &symbol,
		Qty: decimal.NewFromFloat(1),
		Side: alpaca.Buy,
		Type: alpaca.Market,
		TimeInForce: alpaca.Day,
	})

```

This code uses DefaultClient which doesn’t have API keys and so on

U need to use this code

```auto
func main() {
	client := alpaca.NewClient(alpaca.ClientOpts{
		// Alternatively you can set your key and secret using the
		// APCA_API_KEY_ID and APCA_API_SECRET_KEY environment variables
		APIKey: "YOUR_API_KEY",
		APISecret: "YOUR_API_SECRET",
		BaseURL: "https://paper-api.alpaca.markets",
	})
	acct, err := client.GetAccount()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", *acct)

buyOrder, err := client.PlaceOrder(alpaca.PlaceOrderRequest{
		Symbol: symbol,
		Qty: &qty,
		Side: alpaca.Buy,
		Type: alpaca.Market,
		TimeInForce: alpaca.Day,
	})

}

```

> **[GitHub - alpacahq/alpaca-trade-api-go: Go client for Alpaca's trade API](https://github.com/alpacahq/alpaca-trade-api-go)**
>
> Go client for Alpaca's trade API. Contribute to alpacahq/alpaca-trade-api-go development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Navi\_Naisoro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/navi_naisoro/32/5647_2.png) [@Navi\_Naisoro](https://forum.alpaca.markets/u/Navi_Naisoro)\
**Post date:** [November 13, 2023, 5:27pm UTC](https://forum.alpaca.markets/t/403-client-error-forbidden-for-url/4118/10 "2023-11-13T17:27:02Z")

</div>

Found out this a credentials key problem especially when installing a new set of keys after discarding some older ones. First I waited coupla minutes for new keys to populate, second I ensured the config file etc was properly copied new keys. Saved the whole lot and completely shut down my jupyter notebook and restarted the programs. Worked. I believe the old keys remained in the system and needed to be purged completely.
