LSEG Data Library for Python

get_headlines

The get_headlines function allows you to retrieve news headlines.

Module

lseg.data

Syntax

get_headlines(query, count, start, end, order_by)

Parameters

Value Description Data type Optional Default value
query The user search query for news headlines. str No -
count Count to limit the number of headlines. int Yes 10
start Beginning of the date range. str, date, datetime, timedelta Yes None
end End of the date range. str, date, datetime, timedelta Yes None
order_by Sort order for headline items. SortOrder Yes SortOrder.new_to_old

Returned value

A pandas.DataFrame with news headlines, news story ID, and source in columns, and with date as a row index.

Usage

The following example demonstrates how to get the latest three news headlines from 20.03.2021 to the date yesterday:

from datetime import timedelta

import lseg.data as ld


# open session
ld.open_session()

df = ld.news.get_headlines(
    "Refinitiv",
    start="20.03.2021",
    end=timedelta(days=-1),
    count=3
)

print(df.to_string())

# close session
ld.close_session()

This example produces the following output:

                                                                                              headline                                                  storyId sourceCode
versionCreated                                                                                                                                                            
2023-01-10 13:56:18.000                                    TABLE-Indian Corporate Bonds dealt - Jan 10  urn:newsml:newswire.refinitiv.com:20230110:nIfp2GKNJg:1     NS:RFT
2023-01-10 13:23:06.169  SERVICE ALERT - US Market holiday  CME Group - INFORMATION see page <ALERT39>  urn:newsml:newswire.refinitiv.com:20230109:nVEN276186:4     NS:RFT
2023-01-10 13:08:50.297                                                 Europe Barge Freights - Jan 10  urn:newsml:newswire.refinitiv.com:20230110:nIGB69662D:1     NS:RFT

SortOrder

118 words (0:37 mins)