RKD Overview
The Knowledge Direct (RKD) API (formerly known as TRKD API) integrates into your website, trading platform, company intranet/extranet, advisory portal and mobile applications to provide up-to-date financial market data, news and analytics and powerful investment tools.
RKD offers a wide range of Refinitiv' information and services delivered in a request-response scenario via web services using today's industry standard protocols (SOAP/XML and REST/JSON). Connectivity can be via HTTP and HTTPS, over the Internet or Delivery Direct. All data are snapshot (non-streaming) data.
With new HTTP JSON services, developers can integrate RKD information to their application easier then before. This article provides an information regarding the basic knowledge of how to implement RKD JSON application to consume news headlines data with Python language.
RKD News Headline Service Overview
The RKD News service allows you to query for news headlines and also retrieve news content via RKD RetrieveHeadlineML_1 operation. This RetrieveHeadlineML_1 operation provides news headlines that match specific requirements for developers. For complex searches, RetrieveHeadlineML_1 operation supports sophisticated search filters that express complex Boolean criteria. These filters can incorporate keywords, companies, products, etc., as well as meta-data such as story time, news provider, and language – and can be used in a single query.
The service also includes symbol resolution and ambiguous symbol handling.
Note: The number of headlines returned by a response is limited to 1000 headlines in RKD API. Headlines and corresponding stories can only be retrieved for the last 90 days.
RKD JSON application implementation process
The JSON application requires the following steps to consume data from RKD API services
Authentication with RKD Authentication service (RKD Service Token) to get an authen token
Send a JSON request message with the required input information and authen token to the interested RKD service
RKD News Headline Detail
RKD RetrieveHeadlineML_1 URL and Header
The URL enponint for the RKD Quote Service is following: https://api.rkd.refinitiv.com/api/News/News.svc/REST/News_1/RetrieveHeadlineML_1
Header:
- Content-type = application/json;charset=utf-8
- X-Trkd-Auth-ApplicationID = Application ID
- X-Trkd-Auth-Token = Service Token
Method:
- Post
RKD RetrieveHeadlineML_1 Request Message
The RKD News RetrieveHeadlineML_1 operation requires the Filters parameter as a mandatory input for query users interested news headlines. An example of headline request message structure is following
Filters
Complex search criteria are specified by using XML elements called filters and constraints to represent the terms of a Boolean expression. Like the terms of a Boolean expression, these elements contain one or more statements to evaluate, can be combined using logical operators (AND, OR, ANDNOT), and can be nested within other terms. Searches can be constructed to perform free text searches (e.g., look for "Sun" anywhere in the headline), or look for specific meta-data (e.g., COMPANY="SUNW", LANGUAGE="EN", etc.), or both.
You can find more detail regarding the News Filters in RKD Devlopment Guide document.
"trkd_newsheadline.py" Example Application
RKD API News service provides a snapshot (non-streaming) news for the application. To retrieve news headlines data, your application must send the request message in JSON formation along with an authenticated credentials (Service Token) and application id in the request message header.
This section describes how to implement the trkd_newsheadline.py script that performs authentication with the TRDK Service Token, then request for 10 latest news headlines that relates to the user input RIC name via a command line (Text filter).
Implementation Details
- Firstly, we create a file named “trkd_newsheadline.py” in the working directory. Then we write the code to import all required libraries at the top of the source code
2. Since this application needs to send multiple HTTP request messages to RKD Services (for authentication and request news headlines data), we will separate the HTTP request source code to the dedicate function call instead. We start by creating the doSendRequest() function which receives three parameters: the requested URL, request message and request message's header. This function sends the JSON request message to the requested URL and returns the HTTP response via the result parameter. If the HTTP response message status code is not 200 (200 OK), it shows the error detail.
3. Next, Then we add the code to receive the input user name, password and application id from a console
4. Next, we create the CreateAuthorization() function to manage and handle RKD authentication process. We pass user name, password and application id information to the function, then print out the Service Token from RKD in a console.
5. In the CreateAuthorization() function, we create the authentication (authenMsg), the url (authenURL) and headers variables
6. Next, we send this authentication request message, URL and header to the doSendRequest() function. Once the application receives the response Service Token, we send the incoming Service Token back to the caller to prints out the token.
7. After we received the Service Token and that Token is not null, we pass the Service Token and application id to the RetrieveNewsHeadline() function for requesting the news headlines data from RKD RetrieveHeadlineML_1 operation.
8. The RetrieveNewsHeadline() function creates the news headlines request message and sends it to the RKD RetrieveHeadlineML_1 operation via doSendRequest() function.
9. Next, we create the JSON news headlines request message to request latest 10 news headlines of interested RIC. We get user input for the interested RIC code from a console and set it to the request message.
10. Then we send the news headlines request message to RKD News service. If the response HTTP status code is 200 (OK), it prints out result to a console.
Running the application
The application source code is available at GitHub. You can get it via the following git command:
Then input your user name, password and application id. The result is shown in the Figure-1 below
Figure-1: The trkd_newsheadline receives username, password and appid via console
Then, input the interested Symbol for 10 latest news headlines.
Figure-2: The trkd_newsheadline asks for interested Symbol
Then the RKD News application subscribes news headlines from RKD News service and displays the latest 10 news headlines data in console.
Figure-3: The trkd_newsheadline diplsay news headline results
Conclusion
RKD News service provides static (real-time and history) news headlines and news story data content for users. It supports various search Filters (incorporate keywords, companies, products, time, etc) that let users query based on their interest. Users need to authenticate permission with RKD Service Token first, then send the news headlines request message with Service Token and App ID in the request message header to RKD News Server.
References
For further details, please check out the following resources:
- Knowledge Direct API page on the LSEG Developer Community web site.
- Knowledge Direct API Catalog web site
For any question related to this article or Elektron WebSocket API page, please use the Developer Community Q&A Forum.