Skip to content

Commit f5920f5

Browse files
author
Wasin Waeosri
committed
Change log:
1. Add trkd authentication notebook 2. Update README.md
1 parent 343d4ab commit f5920f5

File tree

2 files changed

+104
-11
lines changed

2 files changed

+104
-11
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ The [Thomson Reuters Knowledge Direct (TRKD) API](https://developers.thomsonreut
44

55
TRKD 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.
66

7-
This is an example project that shows how to implement TRKD HTTP JSON client and TRKD Streaming client with Python programming lanugage. This project contains the following example scripts for each TRKD services
7+
This is an example project that shows how to implement TRKD HTTP JSON client and TRKD Streaming client with Python programming lanugage. The project example are in both console and Jupyter Notebook applications.
8+
9+
*Note:* The Jupyter Notebook example does not contain all the same TRKD services service as console example yet. [TBD]
10+
11+
## Application Files
12+
This project contains the following example scripts for each TRKD services
813
- trkd_authen.py: An example application that shows how to authenticate with TRKD service
914
- trkd_quote.py: An example application that shows how to subscribe (all fields and specific fields) the Quote data from TRKD service
1015
- trkd_newsheadline.py: An example application that shows how to subscribe the News Headline data from TRKD service
@@ -14,20 +19,27 @@ This is an example project that shows how to implement TRKD HTTP JSON client and
1419
- trkd_onlinereport.py: An example application that shows how to subscribe the Online Report data from TRKD service
1520
- trkd_chart.py: An example application that shows how to subscribe and download the Chart image data from TRKD service
1621
- trkd_wsstreaming.py: An example application that show how to subscribe the Quote data from TRKD Streming service via a WebSocket connection
22+
- notebook folder:
23+
- *notebook/trkd_authentication.ipynb*: A Jupyter Notebook TRKD Authentication service example
1724
- requestments.txt: A requirement file contains a list of required libraries for HTTP JSON and WebSocket connections.
1825
- docs\TRKD_REST_with_Python.docx: A document that describes the trkd_authen.py and trkd_quote.py applications
1926

2027
All source code and scripts are provided under the Apache 2.0 license. Thye are provided AS IS with no warranty or guarantee of fit for purpose. See the project's LICENSE.md for details.
2128

2229
## Prerequisite
2330
The following softwares are required to use this script
31+
- TRKD API credentials. Please reach out to your Refinitiv sales associate to acquire TRKD access credentials.
2432
- Python 3
2533
- The [requests](http://docs.python-requests.org/en/master/) library
2634
- The [websocket-client](https://pypi.org/project/websocket-client/) library (*version 0.49 or greater*, for trkd_wsstreaming.py application only)
2735
- The [python-dateutil](https://pypi.org/project/python-dateutil/) library (for trkd_wsstreaming.py application only)
36+
- [Jupyter Notebook](https://jupyter.org/) runtime (for the Notebook example application)
2837

2938
All scripts support Python 3 and not compatible with Python 2.
3039

40+
*Note:*
41+
- You can install Jupyter Notebook on your local machine and then test the example on the machine. The alternate choice is a free Jupyter Notebook on cloud environment such as [Azure Notebook](https://notebooks.azure.com/) provided by Microsoft. You can find more details from [this tutorial](https://docs.microsoft.com/en-us/azure/notebooks/tutorial-create-run-jupyter-notebook). If you are not familiar with Jupyter Notebook, the following [tutorial](https://www.datacamp.com/community/tutorials/tutorial-jupyter-notebook) created by DataCamp may help.
42+
3143
## How to run the script
3244
Run the script via the command line (or shell)
3345
```
@@ -95,3 +107,5 @@ For further details, please check out the following resources:
95107
- Add License.md file
96108
- version 1.0.12: March 2019
97109
- Change all scripts to print JSON message in beauty format.
110+
- version 1.5: July 2019
111+
- Add TRKD Authentication Jupyter Notebook.

notebook/trkd_authentication.ipynb

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
{
22
"cells": [
33
{
4-
"cell_type": "code",
5-
"execution_count": null,
4+
"cell_type": "markdown",
65
"metadata": {},
7-
"outputs": [],
86
"source": [
9-
"# Install requests package in a current Jupyter kernal\n",
10-
"import sys\n",
11-
"!{sys.executable} -m pip install requests"
7+
"# TRKD HTTP JSON with Python Example: Authentication\n",
8+
"\n",
9+
"## Overview\n",
10+
"The [Thomson Reuters Knowledge Direct (TRKD) API](https://developers.thomsonreuters.com/thomson-reuters-knowledge-direct-trkd) 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.\n",
11+
"\n",
12+
"TRKD 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.\n",
13+
"\n",
14+
"This is an example project that shows how to implement TRKD HTTP JSON client with Python programming lanugage in Jupyter Notebook.\n",
15+
"\n",
16+
"### TRKD JSON application implementation process\n",
17+
"The JSON application requires the following steps to consume data from TRKD API services\n",
18+
"1. Authentication with TRKD Authentication service to get an authen token\n",
19+
"2. Send a request message with the required input information and authen token to the interested TRKD service"
1220
]
1321
},
1422
{
@@ -17,10 +25,11 @@
1725
"metadata": {},
1826
"outputs": [],
1927
"source": [
20-
"# import required libraries\n",
28+
"# #uncomment if you do not have requests and websocket-client (version 0.49 and above) installed\n",
2129
"\n",
22-
"import requests\n",
23-
"import json"
30+
"# # Install requests package in a current Jupyter kernal\n",
31+
"# import sys\n",
32+
"# !{sys.executable} -m pip install requests"
2433
]
2534
},
2635
{
@@ -29,7 +38,10 @@
2938
"metadata": {},
3039
"outputs": [],
3140
"source": [
32-
"# functions"
41+
"# import required libraries\n",
42+
"\n",
43+
"import requests\n",
44+
"import json"
3345
]
3446
},
3547
{
@@ -83,6 +95,52 @@
8395
"expire = None"
8496
]
8597
},
98+
{
99+
"cell_type": "markdown",
100+
"metadata": {},
101+
"source": [
102+
"#### TRKD Service Token Detail\n",
103+
"##### TRKD Service Token URL and Header\n",
104+
"\n",
105+
"The URL enponint for the TRKD Service Token is following:\n",
106+
"[https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1](https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1)\n",
107+
"\n",
108+
"Header: \n",
109+
"- Content-type = application/json;charset=utf-8\n",
110+
"Method:\n",
111+
"- Post\n",
112+
"\n",
113+
"##### TRKD Service TOKEN Request Message\n",
114+
"\n",
115+
"The CreateServiceToken_1 operation requires the following information to perform authentication\n",
116+
"- ApplicationID\n",
117+
"- Username\n",
118+
"- Password\n",
119+
"\n",
120+
"The request message structure is following\n",
121+
"```\n",
122+
"{\n",
123+
" “CreateServiceToken_Request_1”:{\n",
124+
" “ApplicationID”: <application id>,\n",
125+
" “Username”: <username>,\n",
126+
" “Password”: <password>\n",
127+
" }\n",
128+
"}\n",
129+
"\n",
130+
"```\n",
131+
"The example of the response message is shown below\n",
132+
"```\n",
133+
"{\n",
134+
" \"CreateServiceToken_Response_1\": {\n",
135+
" \"Expiration\": \"2016-09-26T09:42:54.4335265Z\",\n",
136+
" \"Token\": \"674E12E4EF35F181602672D5529D98379D4B42216057C7FF…\"\n",
137+
" }\n",
138+
"}\n",
139+
"```\n",
140+
"- Token: an encrypted, expiring string that securely identifies the service user (aka service Token)\n",
141+
"- Expiration: Token expires after a configurable time period. The default expiration is 90 minutes."
142+
]
143+
},
86144
{
87145
"cell_type": "code",
88146
"execution_count": null,
@@ -169,6 +227,27 @@
169227
"print('Expiration = %s' % expire)"
170228
]
171229
},
230+
{
231+
"cell_type": "markdown",
232+
"metadata": {},
233+
"source": [
234+
"## Conclusion\n",
235+
"All TRKD HTTP JSON applications require authenticaiton to access TRKD data. The application needs to request for Service Token from TRKD server, then keeps a response Service Token for later use in other request message header."
236+
]
237+
},
238+
{
239+
"cell_type": "markdown",
240+
"metadata": {},
241+
"source": [
242+
"## <a href=\"references\"></a>References\n",
243+
"For further details, please check out the following resources:\n",
244+
"* [Thomson Reuters Knowledge Direct API page](https://developers.refinitiv.com/thomson-reuters-knowledge-direct-trkd) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.\n",
245+
"* [Thomson Reuters Knowledge Direct API Catalog](https://www.trkd.thomsonreuters.com/SupportSite/RequestBuilder/requestbuilder.aspx) web site.\n",
246+
"* TRKD Article: [How to implement TRKD JSON application with Python chapter 1: the basic](https://developers.refinitiv.com/article/how-implement-trkd-json-application-python-chapter-1-basic)\n",
247+
"\n",
248+
"For any question related to this tutorial or TRKD API, please use the Developer Community [Q&A Forum](https://community.developers.refinitiv.com/spaces/51/view.html)."
249+
]
250+
},
172251
{
173252
"cell_type": "code",
174253
"execution_count": null,

0 commit comments

Comments
 (0)