# Trying to use barset, giving a weird error

**URL:** https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891
**Category:** Alpaca Trading
**Created:** [February 21, 2023, 4:06pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891 "2023-02-21T16:06:25Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Lord\_Ingram](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@Lord\_Ingram](https://forum.alpaca.markets/u/Lord_Ingram)
#### Post date: [February 21, 2023, 4:06pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/1 "2023-02-21T16:06:25Z")

</div>

Howdy, first time using the forum, lack of documentation brought me here. I’ve been trying to use the get\_barset method, it ends up in giving me an error that reads

404 Client Error: Not Found for url: [https://data.alpaca.markets/v2/bars/1Min?symbols=AAPL&limit=1](https://data.alpaca.markets/v2/bars/1Min?symbols=AAPL&limit=1)

For some reason it is adding my request to the end of my link? I genuinely do not understand how. Here’s my code below.

import alpaca\_trade\_api\_fixed as tradeapi

api\_key = ‘I put my key here’  
api\_secret = ‘I put my private key’  
base\_url = ‘[https://paper-api.alpaca.markets](https://paper-api.alpaca.markets)’

api = tradeapi.REST(api\_key, api\_secret, base\_url, api\_version=‘v2’)

account = api.get\_account()  
print(account)

barset = api.get\_barset(‘AAPL’, ‘1Min’, limit=1)  
bars = barset[‘AAPL’]  
print(bars)

Any help would be greatly appreciated, thank you.

---

<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: [February 21, 2023, 8:54pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/2 "2023-02-21T20:54:55Z")

</div>

@Lord_Ingram Try this

```
     `import alpaca_trade_api as tradeapi`

```

Then, don’t use get\_barset (that is old) do this instead

```
     `barset = api.get_bars('AAPL', '1Min', limit=1)`

```

That should work for you.

---

<div class="post-metadata">

### Author: ![Lord\_Ingram](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@Lord\_Ingram](https://forum.alpaca.markets/u/Lord_Ingram)
#### Post date: [February 22, 2023, 3:24pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/3 "2023-02-22T15:24:44Z")

</div>

I swapped out

```auto
import alpaca_trade_api_fixed as tradeapi

```

with

```auto
import alpaca_trade_api as tradeapi

```

It’s red in the code, when running it gives `ModuleNotFoundError: No module named 'alpaca_trade_api'`

Secondly, I swapped out the get\_barset with get\_bars, it ended up giving a `AttributeError: 'REST' object has no attribute 'get_bars'. Did you mean: 'get_barset'?`

I am utterly stumped on this.

---

<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: [February 22, 2023, 10:28pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/4 "2023-02-22T22:28:14Z")

</div>

@Lord_Ingram You will need to install the package `alpaca_trade_api`. Don’t install `alpaca_trade_api_fixed` (which you may have done), The `alpaca_trade_api_fixed` package is an old version. Then it should work.

```auto
!pip install -q alpaca_trade_api
import alpaca_trade_api as tradeapi

ALPACA_API_KEY_ID_PAPER = 'xxxxxxx'
ALPACA_API_SECRET_KEY_PAPER = 'xxxxxxx'

ALPACA_API_BASE_URL_PAPER = 'https://paper-api.alpaca.markets'

api_paper = alpacaapi.REST(ALPACA_API_KEY_ID_PAPER, 
                           ALPACA_API_SECRET_KEY_PAPER, 
                           ALPACA_API_ENDPOINT_PAPER)

barset = api.get_bars('AAPL', '1Min', limit=1)

```

The github repository for the `alpaca_trade_api` SDK is [here](https://github.com/alpacahq/alpaca-trade-api-python) and has a bit of examples and documentation.

---

<div class="post-metadata">

### Author: ![Lord\_Ingram](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@Lord\_Ingram](https://forum.alpaca.markets/u/Lord_Ingram)
#### Post date: [February 28, 2023, 3:41pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/5 "2023-02-28T15:41:15Z")

</div>

Is there a place to find better documentation? I’ve been scouring online sources and no dice. I uninstalled alpaca\_trade\_api\_fixed and installed alpaca\_trade\_api. I’m still receiving the error “AttributeError: module ‘alpaca\_trade\_api’ has no attribute 'get\_bars”

Here’s the code I tried

> import alpaca\_trade\_api as tradeapi
> 
> ALPACA\_API\_KEY\_ID\_PAPER = ‘xxxxx’  
> ALPACA\_API\_SECRET\_KEY\_ID\_PAPER = ‘xxxxx’  
> ALPACA\_API\_ENDPOINT\_PAPER = ‘[https://paper-api.alpaca.markets](https://paper-api.alpaca.markets)’
> 
> api\_paper = tradeapi.REST(ALPACA\_API\_KEY\_ID\_PAPER,  
> ALPACA\_API\_SECRET\_KEY\_ID\_PAPER,  
> ALPACA\_API\_ENDPOINT\_PAPER)
> 
> barset = tradeapi.get\_bars(‘AAPL’, ‘1Min’, limit=1)

I just want to view AAPL’s performance over the last minute. Will issues such as these be prevalent if I continue using this API?

---

<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: [February 28, 2023, 3:45pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/6 "2023-02-28T15:45:10Z")

</div>

@Lord_Ingram I believe the problem is this line of code

> `barset = tradeapi.get_bars(‘AAPL’, ‘1Min’, limit=1)`

That should be

> `barset = api_paper.get_bars(‘AAPL’, ‘1Min’, limit=1)`

Try that.

---

<div class="post-metadata">

### Author: ![Lord\_Ingram](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@Lord\_Ingram](https://forum.alpaca.markets/u/Lord_Ingram)
#### Post date: [March 1, 2023, 3:42pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/7 "2023-03-01T15:42:58Z")

</div>

That worked! Thank you so very much. If I may ask, where can I find documentation if need be?

---

<div class="post-metadata">

### Author: ![SAF\_SAF](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/saf_saf/32/6889_2.png) [@SAF\_SAF](https://forum.alpaca.markets/u/SAF_SAF)
#### Post date: [July 20, 2025, 6:11pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/8 "2025-07-20T18:11:55Z")

</div>

Im actually running the “example” Step-by-Step to Build a Stock Trading Bot by Matthew Tweed, but it is riddles with errors. I wonder if he even tested it before putting it up!!!

Anyway, the latest error I have is:  
AttributeError: ‘Bar’ object has no attribute ‘time’  
bar is returned by api.get\_bars()

Since the API documentation is horrible and almost non-existent, can some please help.

---

<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: [August 7, 2025, 9:05pm UTC](https://forum.alpaca.markets/t/trying-to-use-barset-giving-a-weird-error/11891/9 "2025-08-07T21:05:10Z")

</div>

[@SAF\_SAF](https://forum.alpaca.markets/u/saf_saf) Could you paste the code you are having issues with. I may ba able to help troubleshoot.
