# Last updated news for get\_news

**URL:** <https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071>\
**Category:** Getting Started with Alpaca\
**Created:** [April 23, 2024, 2:13am UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071 "2024-04-23T02:13:43Z")\
**Posts on this page:** 5\
**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 23, 2024, 2:13am UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071/1 "2024-04-23T02:13:43Z")

</div>

Hi all,

I want to get the last 20 mins news for a stock. What is the last update for get\_news method?  
Is it real time?

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 23, 2024, 12:10pm UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071/2 "2024-04-23T12:10:08Z")

</div>

@huseyin Take a look at the [news endpoint](https://docs.alpaca.markets/reference/news-3). You can get news articles between any two datetimes and includes current news. If a end is not specified, the default value is the current time. One thing to note is the maximum articles returned is 50 so you should check the page token and request more pages if it is not empty. May not be an issue with only the last 20 minutes but something to be aware of. I can provide a code sample in python if needed.

---

<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 23, 2024, 2:05pm UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071/3 "2024-04-23T14:05:16Z")

</div>

Thank you so much.  
But the documentation you shared is not clear.  
I am using the following script:  
now = datetime.now()  
five\_mins\_ago = now - timedelta(minutes=20)  
news\_start\_time = pd.to\_datetime(five\_mins\_ago).tz\_localize(‘America/New\_York’).isoformat()  
news\_end\_time = pd.to\_datetime(now).tz\_localize(‘America/New\_York’).isoformat()  
news\_last\_20\_mins = rest\_client.get\_news(‘TSLA’, news\_start\_time, news\_end\_time)

If nothing wrong with it, I will stick to my script.  
Please let me know  
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 23, 2024, 5:07pm UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071/4 "2024-04-23T17:07:25Z")

</div>

I personally do not like using the datetime methods and prefer only using the pandas methods. So, here is my implementation.

```auto
!pip install -q alpaca-py
import pandas as pd

from alpaca.data.historical.news import NewsClient
from alpaca.data.requests import NewsRequest

API_KEY = 'xxxxx'
API_SECRET_KEY = 'xxxxx'
news_client = NewsClient(api_key=API_KEY, secret_key=API_SECRET_KEY)

current_time = pd.Timestamp.now(tz="America/New_York")
time_20_minutes_previous = current_time - pd.Timedelta(minutes=20)

news_last_20_mins = news_client.get_news(NewsRequest(
    symbols='TSLA',
    start=time_20_minutes_previous,
    end=current_time,
    limit=50)
)

```

Note this will only return the first 50 articles. This probably isn’t an issue if only fetching news for 20 minutes for a single symbol, but if more symbols or a longer timeframe is requested, one should probably implement some sort of loop to check for multiple pages and fetch those as necessary.

---

<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 23, 2024, 8:48pm UTC](https://forum.alpaca.markets/t/last-updated-news-for-get-news/14071/5 "2024-04-23T20:48:24Z")

</div>

Thank you so much  
I appricate
