How To Connect to News With Python

Hello,
I am trying to connect to RDP news directly in python without having the terminal in the same machine.
import lseg.data as ld
import os
os.environ["LD_LIB_CONFIG_PATH"] = r"C:\\Users\\padadmin\\PycharmProjects\\pythonProject\\Repos\\pwm-pad\\APIs\\Configuration"
ld.open_session()
Where I have the json file like this:
{
"sessions": {
"platform": {
"ldpv2auth": {
"app-key": "MYAPIK",
"client_id": "GESG1-xxxxx",
"client_secret": "psw"
}
}
}
}
A couple of questions:
a) Is that json format correct ? If not how to fix it so that I can have access to the news WITHOUT having the terminal running behind ?
b) How can I find the psw if I do not remember it anymore ?
Thanks
Best Answer
-
According to the available scopes, you don't have permission to access news. Please contact your LSEG Representative or Account Manager to check your permission.
Regarding the Filings, the code looks like this:
import os os.environ["LD_LIB_CONFIG_PATH"] = "../../Configuration" import lseg.data as ld from lseg.data.content import filings ld.open_session("platform.ldpv2") query = '{ FinancialFiling(filter: {AND: [{FilingDocument: {DocumentSummary: {FeedName: {EQ: "Edgar"}}}}, {FilingDocument: {DocumentSummary: {FormType: {EQ: "10-Q"}}}}, {FilingDocument: {DocumentSummary: {FilingDate: {BETWN: {FROM: "2020-01-01T00:00:00Z", TO: "2020-12-31T00:00:00Z"}}}}}]}, sort: {FilingDocument: {DocumentSummary: {FilingDate: DESC}}}, limit: 10) { _metadata { totalCount } FilingDocument { Identifiers { Dcn } DocId FinancialFilingId DocumentSummary { DocumentTitle FeedName FormType HighLevelCategory MidLevelCategory FilingDate SecAccessionNumber SizeInBytes } FilesMetaData { FileName MimeType } } }}' definition = filings.search.Definition(query=query) response = definition.get_data() print(response.data.df) #Download a file response.data.files[0].download(path="download")
For more information regarding to the Filings API, please refer to the following pages:
0
Answers
-
Hello @Aleniles
Yes, the format is correct. The format for the
Platform Session configuration is as follows:{
"logs": {
"level": "debug",
"transports": {
"console": {
"enabled": false
},
"file": {
"enabled": false,
"name": "lseg-data-lib.log"
}
}
},
"sessions": {
"default": "ldpv2",
"platform": {
"ldpv1": {
"app-key": "App-Key",
"username": "V1 Machine-ID",
"password": "Password"
},
"ldpv2":{
"client_id": "V2 Client-ID",
"client_secret": "Client Secret",
"app-key": ""
}
}
}
}Note:
- Based on my tested, you can leave the "app-key" on the V2 configuration empty (just "").
- About V1 vs V2, check —> article.
Then you can find more resources about getting News via the Data Library:
- article.
About the password, please contact your LSEG Representative or Account Manager to help you with the password resetting.
0 -
Top, so in my case is V1.
I managed to get the <lseg.data.session.Definition object at 0x214fa2d8710 {name='ldpv1'}> message although this doesn't mean that I am connected successfully, right? How could I check that I am connected successfully ?
When I run this:
ld.news.get_headlines("LSEG.L", start="20.08.2024", end=timedelta(days=-4), count=3)
I am getting this:
No user scope for key=/data/news/v1/headlines, method=GET.
ScopeError: Insufficient scope for key=/data/news/v1/headlines, method=GET.
Required scopes: {'trapi.data.news.read'}
Available scopes: {'trapi.data.symbology.advanced.read', 'trapi.search.explore.read', 'trapi.cfs.claimcheck.read', 'trapi.data.filings.metadata', 'trapi.auth.cloud-credentials', 'trapi.metadata.read', 'trapi.search.metadata.read', 'trapi.data.filings.retrieval', 'trapi.graphql.subscriber.access', 'trapi.data.filings.search', 'trapi.data.symbology.read'}
Missing scopes: {'trapi.data.news.read'}
What method should I use then based on the available one ?0 -
Basically seems that these are in scope:
Available scopes: {'trapi.data.symbology.advanced.read', 'trapi.search.explore.read', 'trapi.cfs.claimcheck.read', 'trapi.data.filings.metadata', 'trapi.auth.cloud-credentials', 'trapi.metadata.read', 'trapi.search.metadata.read', 'trapi.data.filings.retrieval', 'trapi.graphql.subscriber.access', 'trapi.data.filings.search', 'trapi.data.symbology.read'}
Maybe it works with filings ? I haven't seen any example here https://github.com/LSEG-API-Samples/Example.DataLibrary.Python/blob/lseg-data-examples/Examples/1-Access/EX-1.01.05-News.ipynb
Are you able to provide a snippet that I could use for Filings that is in my scope ?0 -
Hello @Aleniles
The <lseg.data.session.Definition object at 0x214fa2d8710 {name='ldpv1'}> message indicates that you have open the session succesfully.
About the "Missing scopes: {'trapi.data.news.read'}" message, it is a permission issue. Please follow my colleague @Jirapongse suggestion below.
0 -
I am trying to filter by specific OrganizationalIDs
I tried adding:
filter: {
AND: [
{FilingDocument: {DocumentSummary: {FeedName: {EQ: "Edgar"}}}},
{FilingDocument: {DocumentSummary: {FormType: {EQ: "10-K"}}}},
{FilingDocument: {DocumentSummary: {FilingDate: {BETWN: {FROM: "2023-12-01T00:00:00Z", TO: "2025-03-31T00:00:00Z"}}}}},
{FilingDocument: {Identifiers: {OrganizationId: {IN: ["4295914405", "4295905573", "4295904620"]}}}}]
},
And it seems to filter correctly.
However I am not able to download all documents for all the ORG IDs it works only for one (NVDA). Could you provide maybe a snippet that works?0 -
response.data.files is an array. You can use an index to access each file.
To download all files, you can try this one.
response.data.files.download(path="download")
0
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
- 684 Datastream
- 1.4K DSS
- 615 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
- 249 ETA
- 554 WebSocket API
- 37 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
- 643 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
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 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 中文论坛