Get_news - count of news articles for a RIC, date range and topic

Hi,
As above title please, looking to run a count of news articles for a particular RIC, date range and ‘topic’. I.e. TSLA.O, 6th November 2023 - 10 November 2023, topic=SIGDEV.
I’d like a count of news articles per day.
Is this possible?
I’m aware of how to run get news story for the above, but it’s time consuming. I’d just like to run a count of news articles or headlines - that meet the above criteria - per each day within the specified date range.
Thank you
Best Answer
-
Hi @di.ti,
I believe it might be best to use the RD Lib. for Python's functionanity called 'Delivery' in the following way:
import refinitiv.data as rd
try: # The following libraries are not available in Codebook, thus this try loop
rd.open_session(
config_name="C:\\Example.DataLibrary.Python-main\\Configuration\\refinitiv-data.config.json", # this is where my config file is located
name="desktop.workspace") # rdp.platform
except:
rd.open_session()
company = "TSLA.O"
start = "2023-11-06"
end = "2023-11-10"
source = "SIGDEV"
request_definition = rd.delivery.endpoint_request.Definition(
url=f"https://api.refinitiv.com/data/news/v1/headlines?query={company} and {source} daterange:"{start},{end}"",
method = rd.delivery.endpoint_request.RequestMethod.GET)
response = request_definition.get_data()
response.data.raw['meta']['count']Does this meet your need?
N.B.: You can find info abou this endpoint (which is named a `url` above) here; e.g.: "Limit of headline (default 10, range value: [0, 100])"0
Answers
-
@jonathan.legrandHi
Thank you for this. This works at generating a count of all articles in the date range, but any chance that it could generate a count of how many articles meet this criteria for each day within the start date and end date?
0 -
@di.ti
,
in that case, this should work:company:str="TSLA.O"
start: str ="2023-11-01"
end: str ="2023-11-10"
source: str ="SIGDEV"
strt_dte:datetime=datetime.strptime(start,'%Y-%m-%d')
strt_dtep1:datetime=datetime.strptime(start,'%Y-%m-%d') + timedelta(days=1)
end_dte:datetime=datetime.strptime(end, '%Y-%m-%d')
delta:timedelta=end_dte-strt_dte
for i,j,k in zip(
[(strt_dte+timedelta(days=i)).strftime('%Y-%m-%d') for i in range(delta.days+1)],
[(strt_dtep1+timedelta(days=i)).strftime('%Y-%m-%d') for i in range(delta.days+1)],
[i for i in range(delta.days+1)]):
request_definition: rd.delivery._data._endpoint_definition.Definition=rd.delivery.endpoint_request.Definition(
url=f"https://api.refinitiv.com/data/news/v1/headlines?query={company}+and+{source}+daterange:\{i},{j}\",
method=rd.delivery.endpoint_request.RequestMethod.GET)
response:rd.delivery._data._response.Response=request_definition.get_data()
if k==0:
req_def_lst:list[int]=[response.data.raw['meta']['count']]
else:
req_def_lst.append(response.data.raw['meta']['count'])
print(f"{i}to{j}:{response.data.raw['meta']['count']} article(s)")
print(req_def_lst)0 -
@jonathan.legrand, Works perfect! Thank you very much!Hi0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 616 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛