How to query the news sources

Hello, Is there an endpoint to get a list of news sources? I would like to have an overview for querying news and filtering by source among those that I choose to select. For illustration here's a Python snippet:

from typing import List, Iterable
import refinitiv.data as rd
import pandas as pd


def get_news_sources() -> List[str]:
...


def get_news(symbol: str, sources: Iterable[str]) -> pd.DataFrame:
source_filters = "AND ".join([f"SOURCE:{source}" for source in sources])
return rd.news.get_headlines(query=f"R:{symbol} {source_filters}")


sources = get_news_sources()

selected_sources = ...
ticker = ...

headlines = get_news(ticker, filter(lambda x: x in selected_sources, sources)

display(headlines)

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @alexandre.sonderegger

    Thank you for reaching out to us.

    I found the news source endpoint is available on the platform.rdp session. It is not available on the desktop session.

    news_meta_url = 'https://api.refinitiv.com/data/news/v1/metadata'
    request_definition = ld.delivery.endpoint_request.Definition(
        url = news_meta_url,
        method = ld.delivery.endpoint_request.RequestMethod.GET,
        query_parameters = {"group": "Source","limit":100}
    )
    response = request_definition.get_data()
    response.data.raw

    1729069696649.png

    I am using the Endpoint example in the LD library.

Answers