|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | 3 | { |
4 | | - "cell_type": "code", |
5 | | - "execution_count": null, |
| 4 | + "cell_type": "markdown", |
6 | 5 | "metadata": {}, |
7 | | - "outputs": [], |
8 | 6 | "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" |
12 | 20 | ] |
13 | 21 | }, |
14 | 22 | { |
|
17 | 25 | "metadata": {}, |
18 | 26 | "outputs": [], |
19 | 27 | "source": [ |
20 | | - "# import required libraries\n", |
| 28 | + "# #uncomment if you do not have requests and websocket-client (version 0.49 and above) installed\n", |
21 | 29 | "\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" |
24 | 33 | ] |
25 | 34 | }, |
26 | 35 | { |
|
29 | 38 | "metadata": {}, |
30 | 39 | "outputs": [], |
31 | 40 | "source": [ |
32 | | - "# functions" |
| 41 | + "# import required libraries\n", |
| 42 | + "\n", |
| 43 | + "import requests\n", |
| 44 | + "import json" |
33 | 45 | ] |
34 | 46 | }, |
35 | 47 | { |
|
83 | 95 | "expire = None" |
84 | 96 | ] |
85 | 97 | }, |
| 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 | + }, |
86 | 144 | { |
87 | 145 | "cell_type": "code", |
88 | 146 | "execution_count": null, |
|
169 | 227 | "print('Expiration = %s' % expire)" |
170 | 228 | ] |
171 | 229 | }, |
| 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 | + }, |
172 | 251 | { |
173 | 252 | "cell_type": "code", |
174 | 253 | "execution_count": null, |
|
0 commit comments