Skip to content

Commit 3119505

Browse files
author
Wasin Waeosri
committed
change log:
1. Add article to README.md and notebook 2. Add flowchart to notebook
1 parent 69ab3f7 commit 3119505

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
This example shows how to writing the [Elektron WebSocket API](https://developers.refinitiv.com/elektron/websocket-api) application to subscribe Machine Readable News (MRN) from Thomson Reuters Enterprise Platform (TREP). The example just connects to TREP via a WebSocket connection, then subscribes and display MRN News data in a console or classic Jupyter Notebook. The project are implemented with Python language for both console and Jupyter Notebook applications, but the main concept for consuming and assembling MRN News messages are the same for all technologies.
1010

11+
Please see a full documentation of this example application in [this article](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
12+
1113
*Note:* The news message is in UTF-8 JSON string format. Some news messages that contains special unicode character may not be able to show in Windows OS console (cmd, git bash, powershell, etc) due to the OS limitation. Those messages will be print as ```UnicodeEncodeError exception. Cannot decode unicode character``` message in a console instead.
1214

1315
## Machine Readable News Overview
@@ -28,7 +30,7 @@ The data goes through the following series of transformations:
2830
3. The compressed JSON is split into a number of fragments (BUFFER or Base64 ascii string) which each fit into a single update message
2931
4. The data fragments are added to an update message as the FRAGMENT field value in a FieldList envelope
3032

31-
Therefore, in order to parse the core content data, the application will need to reverse this process. The WebSocket application also need to convert a received Base64 string in a FRAGMENT field to bytes data before further process this field. This application uses Python [base64](https://docs.python.org/3/library/base64.html) and [zlib](https://docs.python.org/3/library/zlib.html) modules to decode Base64 string and decompress JSON string.
33+
Therefore, in order to parse the core content data, the application will need to reverse this process. The WebSocket application also need to convert a received Base64 string in a FRAGMENT field to bytes data before further process this field. This application uses Python [base64](https://docs.python.org/3/library/base64.html) and [zlib](https://docs.python.org/3/library/zlib.html) modules to decode Base64 string and decompress JSON string.
3234

3335
If you are not familiar with MRN concept, please visit the following resources which will give you a full explanation of the MRN data model and implementation logic:
3436
* [Webinar Recording: Introduction to Machine Readable News](https://developers.refinitiv.com/news#news-accordion-nid-12045)
@@ -189,6 +191,7 @@ News = {'altId': 'nIdw5d8Hwd', 'audiences': ['NP:CNRA', 'NP:IDXN'], 'body': 'Lap
189191
* [Refinitiv Elektron SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.
190192
* [Refinitiv Elektron WebSocket API page](https://developers.refinitiv.com/websocket-api).
191193
* [Developer Webinar Recording: Introduction to Electron WebSocket API](https://www.youtube.com/watch?v=CDKWMsIQfaw).
194+
* [Introduction to Machine Readable News with Elektron WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
192195
* [Machine Readable News (MRN) & N2_UBMS Comparison and Migration Guide](https://developers.refinitiv.com/article/machine-readable-news-mrn-n2_ubms-comparison-and-migration-guide).
193196
* [Introduction to Machine Readable News (MRN) with Elektron Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).
194197
* [MRN Data Models and Elektron Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).

notebook/images/mrn_flowchart.png

45 KB
Loading

notebook/mrn_notebook_app.ipynb

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"cell_type": "markdown",
5353
"metadata": {},
5454
"source": [
55+
"Please see a full documentation of this example application in [this article](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).\n",
56+
"\n",
5557
"If you are not familiar with MRN concept, please visit the following resources which will give you a full explanation of the MRN data model and implementation logic:\n",
5658
"* [Webinar Recording: Introduction to Machine Readable News](https://developers.refinitiv.com/news#news-accordion-nid-12045)\n",
5759
"* [Introduction to Machine Readable News (MRN) with Elektron Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).\n",
@@ -197,19 +199,8 @@
197199
"The subsequent update contains the fields necessary to identify the MRN data item, the order of this fragment among all the fragments for this item, and the fragment itself. The other point to note is that (for a Multi fragment item), Update messages with FRAG_NUM >1 will have fewer FIDs as the metadata is included in the first Update message (FRAG_NUM=1) for that item\n",
198200
"\n",
199201
"#### News Fragments simple handle logic\n",
200-
"1. Check if incoming message FRAG_NUM value =1\n",
201-
"2. If yes, this message is the first update message\n",
202-
" * convert FRAGMENT value from Base64 ascii string to bytes value with [base64](https://docs.python.org/3/library/base64.html) module\n",
203-
" * if FRAGMENT bytes length equal to TOT_SIZE value, it means this is a single fragment news. \n",
204-
" * The application uses [zlib](https://docs.python.org/3/library/zlib.html) module to unzip the FRAGMENT bytes value to JSON string\n",
205-
" * if not, it means this message is a first fragment of multiple fragments news. \n",
206-
" * The application then keeps news update data in dictionary object with GUID as a key.\n",
207-
"3. If FRAG_NUM value > 1, it means this is a subsequent Update message for multiple fragments news\n",
208-
" * get associate news data (previous multi-fragments) from GUID\n",
209-
" * convert FRAGMENT value from Base64 ascii string to bytes value and add it to current multi-fragments\n",
210-
" * if this multi-fragments bytes length equal to TOT_SIZE value, it means this news fragment is completed and all fragments have been received. \n",
211-
" * The application unzip this multi-fragments bytes value to JSON string\n",
212-
" * if not, the application continue wating for more fragments from furthure update for the same GUID\n"
202+
"\n",
203+
"![title](./images/mrn_flowchart.png)\n"
213204
]
214205
},
215206
{
@@ -2153,6 +2144,7 @@
21532144
"* [Refinitiv Elektron SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.\n",
21542145
"* [Refinitiv Elektron WebSocket API page](https://developers.refinitiv.com/websocket-api).\n",
21552146
"* [Developer Webinar Recording: Introduction to Electron WebSocket API](https://www.youtube.com/watch?v=CDKWMsIQfaw).\n",
2147+
"* [Introduction to Machine Readable News with Elektron WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).\n",
21562148
"* [Machine Readable News (MRN) & N2_UBMS Comparison and Migration Guide](https://developers.refinitiv.com/article/machine-readable-news-mrn-n2_ubms-comparison-and-migration-guide).\n",
21572149
"* [Introduction to Machine Readable News (MRN) with Elektron Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).\n",
21582150
"* [MRN Data Models and Elektron Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).\n",
@@ -2185,7 +2177,7 @@
21852177
"name": "python",
21862178
"nbconvert_exporter": "python",
21872179
"pygments_lexer": "ipython3",
2188-
"version": "3.7.3"
2180+
"version": "3.7.4"
21892181
}
21902182
},
21912183
"nbformat": 4,

0 commit comments

Comments
 (0)