# What is the equivalent of get\_barset in alpaca-py?

**URL:** https://forum.alpaca.markets/t/what-is-the-equivalent-of-get-barset-in-alpaca-py/14053
**Category:** Getting Started with Alpaca
**Created:** [April 17, 2024, 3:19am UTC](https://forum.alpaca.markets/t/what-is-the-equivalent-of-get-barset-in-alpaca-py/14053 "2024-04-17T03:19:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![huseyin](https://avatars.discourse-cdn.com/v4/letter/h/b782af/32.png) [@huseyin](https://forum.alpaca.markets/u/huseyin)
#### Post date: [April 17, 2024, 3:19am UTC](https://forum.alpaca.markets/t/what-is-the-equivalent-of-get-barset-in-alpaca-py/14053/1 "2024-04-17T03:19:06Z")

</div>

Hi all,

I want to get the latest price info for a stock.  
I found that get\_barset() was doing it with the old API.  
What is the equivalent of get\_barset() in alpaca-py?

Thanks

---

<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: [April 17, 2024, 1:25pm UTC](https://forum.alpaca.markets/t/what-is-the-equivalent-of-get-barset-in-alpaca-py/14053/2 "2024-04-17T13:25:38Z")

</div>

@huseyin Use the [get\_stock\_bars method](https://alpaca.markets/sdks/python/api_reference/data/stock/historical.html#get-stock-bars) to get bars using the alpaca-py SDK. Maybe like this

```auto
symbol_or_symbols = 'WCEO'

end = pd.to_datetime('now', utc=True).tz_convert('America/New_York')
start = end - pd.Timedelta('20Day')

# Fetch today and yesterday's data and convert to dataframe
bars = data_client.get_stock_bars(StockBarsRequest(
                                  symbol_or_symbols=symbol_or_symbols,
                                  timeframe=TimeFrame(5, TimeFrameUnit.Minute),
                                  start=start,
                                  end=end,
                                  feed=DataFeed.SIP,
                                  )).df

```

However, a better way to get the latest bar is to use the [get\_latest\_bar method](https://alpaca.markets/sdks/python/api_reference/data/stock/historical.html#get-stock-latest-bar). That way you do not need to deal with times. You should check the bar datetime if doing that. It may be quite old.
