1. Home
2. Article Catalog
3. Learn Refinitiv WebSocket APIs with Postman

Ariticle

Learn Refinitiv WebSocket APIs with Postman

Author:
Jirapongse Phuriphanvichai

WebSocket is a bi-directional, full-duplex communication standard over a single TCP connection. It allows users to open a two-way interactive communication session between a client and a server, send messages to a server, and retrieve responses without having to poll a server. WebSocket can be used in various types of applications, such as Real-Time applications, Gaming applications, and Chat applications.

Many Refinitiv Real-Time solutions support WebSocket protocol, such as Refinitiv Real-Time Distribution System (RTDS), Refinitiv Real-Time Optimized (RTO), Refinitiv Contribution Channel (RCC), Streaming Price for Wealth, and Refinitiv Knowledge Direct Streaming. This article demonstrates how to use Postman to establish WebSocket connections to Refinitiv Real-Time products to retrieve or contribute real-time financial data. It doesn’t require any coding skills to use Postman so users without programming knowledge can use the Postman workspace provided in this article to test or learn Refinitiv WebSocket APIs.

# Postman

Postman is an API client that helps users to create, share, validate and document APIs. Typically, we use Postman to construct simple or complex HTTP request messages with payload, send HTTP request messages to REST APIs, and verify retrieved HTTP responses. Moreover, the HTTP request messages can be saved and shared with other users.

Refinitiv provides several Postman collections that demonstrate how to use Refinitiv REST APIs, such as Datascope Select REST Tutorials Postman collection, Refinitiv Tick History REST Tutorials Postman collection, and Refinitiv Data Platform Postman Starter Collection and Tutorial Samples

Fortunately, at the time of this writing, Postman (9.23.2) supports WebSocket requests in BETA.

This feature allows users to establish connections to WebSocket servers, send messages to the servers, and retrieve response messages, as follows.

1.    Enter the WebSocket URL and then click on Connect to establish a WebSocket connection to the server

If Postman can establish a WebSocket connection to the server, you will see the Connected status and message.

2.    Next, compose a message, specify a message type, such as JSON, and then send it to the server.

3.    Then, you can verify the sent and retrieved messages in the Messages window.

The up arrow indicates sent messages while the down arrow indicates retrieved messages.

4.    Finally, click the Disconnect button to cut the WebSocket connection.

# Refinitiv Real-Time WebSocket APIs Postman Workspace

The Refinitiv Real-Time WebSocket APIs workspace is a public workspace in Postman that demonstrates how to use Refinitiv Real-Time WebSocket APIs. It contains:

1. Two Postman collections
• REST API: Refinitiv Authentication Services: This contains the HTTP requests used to authenticate users and get access tokens from the Refinitiv Data Platform (RDP) and Refinitiv Knowledge Direct (RKD)
• Refinitiv Data Platform APIs – RTO: This provides REST APIs for getting tokens, refreshing tokens, and querying server endpoints when connecting to the Refinitiv Real-Time Optimized and Streaming Price for Wealth solutions.
• Refinitiv Data Platform APIs – RCC:  This provides REST APIs for getting tokens, and refreshing tokens when connecting to the Refinitiv Contribution Channels solution.
• Refinitiv Knowledge Direct: This provides a REST API for getting tokens when connecting to the Refinitiv Knowledge Direct solution.
• Refinitiv Real-Time WebSocket APIs: This contains five WebSocket connections that demonstrate how to use WebSocket APIs on different Refinitiv Real-Time solutions.
• Refinitiv Real-Time Cloud Subscriptions demonstrates how to establish a WebSocket connection to Refinitiv Real-time Optimized, Refinitiv Knowledge Direct Streaming, and Streaming Price for Wealth solutions to retrieve real-time financial data.
• Refinitiv Contribution Channels (RCC) demonstrates how to establish a WebSocket connection to Refinitiv Contribution Channels to contribute real-time financial data to the Refinitiv Real-Time network.
• Refinitiv Real-Time Distribution Subscriptions demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to retrieve real-time financial data.
• Refinitiv Real-Time Distribution Contributions (ATS) demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to contribute real-time financial data to Advanced Transformation System.
• Refinitiv Real-Time Distribution Contributions (RTDS) demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to contribute real-time financial data to a cache in Refinitiv Real-Time Distribution System.
2. One Postman environment
• Refinitiv WebSocket Environment: It contains environment variables, such as credentials, servers, and services information used by the Refinitiv Authentication Services and Refinitiv Real-Time WebSocket APIs Postman collections.

Users can fork these Postman items to their own workspaces.

Please follow these five steps to fork the Refinitiv Real-Time WebSocket APIs Postman Workspace to a Postman workspace.

### 1.    Create a new Postman workspace

Set a workspace name, such as “My Refinitiv WebSocket APIs”, set the Visibility to Personal, and then click the Create Workspace button.

The new workspace will appear on the list.

### 2.    Open the Refinitiv Real-Time WebSocket APIs Postman Workspace

The Refinitiv Real-Time WebSocket APIs Postman workspace is in the public workspace so you can search it in Postman by clicking on “Search Postman”.

Then, enter “Refinitiv Real-Time WebSocket APIs”.

Click on the Refinitiv Real-Time WebSocket APIs to open the workspace.

This workspace will be added to the workspace list.

### 3.    Fork the REST API: Refinitiv Authentication Services collection

Select the Refinitiv Real-Time WebSocket APIs workspace from the workspace list, and then select “View more actions” of the REST API: Refinitiv Authentication Services collection to fork this collection.

Then, enter the fork label, select the workspace (My Refinitiv WebSocket APIs) created in the first step, uncheck “Watch original collection”, and then click on the Fork Collection button.

The forked collection will be created in the selected workspace.

### 4.    Fork the Refinitiv Real-Time WebSocket APIs collection

Select the Refinitiv Real-Time WebSocket APIs workspace from the workspace list, and then select “View more actions” of the Refinitiv Real-Time WebSocket APIs collection to fork this collection.

Then, enter the fork label, select the workspace (My Refinitiv WebSocket APIs) created in the first step, and then click on the Fork Collection button.

The forked collection will be created in the selected workspace.

### 5.    Fork the Refinitiv WebSocket Environment

Select the Refinitiv Real-Time WebSocket APIs workspace from the workspace list, and then select “View more actions” of the Refinitiv WebSocket Environment to fork this environment.

Then, enter the fork label, select the workspace (My Refinitiv WebSocket APIs) created in the first step, and then click on the Fork Environment button.

The forked environment will be created in the selected workspace.

At this point, the workspace (My Refinitiv WebSocket APIs) contains two Postman collections and one Postman environment.

Tips: Users can create multiple forked Refinitiv WebSocket Environment environments. For example, one environment contains settings for Refinitiv Real-Time Optmizied and another environment contains settings for Refinitiv Contributions Channels.

# Setup the Postman Environment Variables

This section demonstrates how to set Postman environment variables to connect to different Refinitiv Real-Time solutions.

## 1.    Refinitiv Real-Time Cloud Subscriptions

### Refinitiv Knowledge Direct Streaming

This WebSocket connection demonstrates how to establish a WebSocket connection to Refinitiv Real-time Optimized, Refinitiv Knowledge Direct Streaming, and Stream Price for Wealth solutions to retrieve real-time financial data. It also demonstrates how to send a message to inform the server regarding the server’s role in warm standby. It depends on the REST API: Refinitiv Authentication Services Postman collection to authenticate users and get tokens.

Note:

• The value of the WEBSOCKET_SERVER variable when connecting to the Refinitiv Real-Time Optimized or Pricing Stream for Wealth can be retrieved from the 3. Get Refinitiv Real-Time Optimized WebSocket Servers request in the REST API: Refinitiv Authentication Services Postman collection.  After that, select the endpoint according to the required location, and then copy the value in the “endpoint” attribute to the WEBSOCKET_SERVER variable. For example:
    	
...
{
"port": 443,
"location": [
"ap-northeast-1a"
],
"transport": "websocket",
"provider": "aws",
"endpoint": "ap-northeast-1-aws-1-lrg.optimized-pricing-api.refinitiv.net",
"dataFormat": [
"tr_json2"
]
},
...




• The SERVICE_ID variable is used in the Service Based Warm Standby message. Its value is a service ID of the REALTIME_SERVICE which can be retrieved from the source directory refresh message. The service ID is in the “Key” attribute of the map entry of the REALTIME_SERVICE. Then, copy the value to the SERVICE_ID variable. For example:
    	
...
"Map": {
"KeyType": "UInt",
"Entries": [
{
"Key": 257,
"FilterList": {
"Entries": [
{
"ID": 1,
"Action": "Set",
"Elements": {
"Name": "ELEKTRON_DD",
"SupportsQoSRange": 0,
"Capabilities": {
...




• The WARM_STANDY_MODE variable is used in the Login Based Warm Standby and Service Based Warm Standby messages. Setting its value to 0 indicates that the connected server is in an active role. Setting its value to 1 indicates that the connected server is in a standby role. For more information regarding the Warm Standby feature, please refer to the Introduction to Refinitiv Real-Time SDK Warm Standby Feature article.
• Refinitiv Knowledge Direct Streaming doesn’t support the Warm Standby feature.

## 2.    Refinitiv Contribution Channels (RCC)

This WebSocket connection demonstrates how to establish a WebSocket connection to Refinitiv Contribution Channels to contribute real-time financial data to the Refinitiv Real-Time network. It depends on the REST API: Refinitiv Authentication Services Postman collection to authenticate users and get tokens.

Note: The client ID could be the machine ID.

## 3.    Refinitiv Real-Time Distribution Subscriptions

This WebSocket connection demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to retrieve real-time financial data. It also demonstrates how to send a message to inform the server regarding the server’s role in warm standby.

Note:

• The SERVICE_ID variable is used in the Service Based Warm Standby message. Its value is a service ID of the REALTIME_SERVICE which can be retrieved from the source directory refresh message. The service ID is in the “Key” attribute of the map entry of the REALTIME_SERVICE. Then, copy the value to the SERVICE_ID variable. For example:
    	
...
"Map": {
"KeyType": "UInt",
"Entries": [
{
"Key": 257,
"FilterList": {
"Entries": [
{
"ID": 1,
"Action": "Set",
"Elements": {
"Name": "ELEKTRON_DD",
"SupportsQoSRange": 0,
"Capabilities": {
...




• The WARM_STANDY_MODE variable is used in the Login Based Warm Standby and Service Based Warm Standby messages. Setting its value to 0 indicates that the connected server is in an active role. Setting its value to 1 indicates that the connected server is in a standby role. For more information regarding the Warm Standby feature, please refer to the Introduction to Refinitiv Real-Time SDK Warm Standby Feature article.

## 4.    Refinitiv Real-Time Distribution Contributions (ATS)

This WebSocket connection demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to contribute real-time financial data to Advanced Transformation System.

## 5.    Refinitiv Real-Time Distribution Contributions (RTDS)

This WebSocket connection demonstrates how to establish a WebSocket connection to Refinitiv Real-Time Distribution System to contribute real-time financial data to a cache in Refinitiv Real-Time Distribution System.

# Summary

This article introduces the Refinitiv Real-Time WebSocket APIs workspace in Postman that demonstrates how to establish WebSocket connections to Refinitiv Real-Time products including Refinitiv Real-Time Distribution System (RTDS), Refinitiv Real-Time Optimized (RTO), Refinitiv Contribution Channel (RCC), Streaming Price for Wealth, and Refinitiv Knowledge Direct Streaming to retrieve or contribute real-time financial data.

The workspace contains two Postman collections and one Postman environment. The first Postman collection is the REST API: Refinitiv Authentication Services collection containing the HTTP requests used to authenticate users and get access tokens from the Refinitiv Data Platform (RDP) and Refinitiv Knowledge Direct (RKD). The second collection is the Refinitiv Real-Time WebSocket APIs collection containing five WebSocket connections that demonstrate how to use WebSocket APIs on different Refinitiv solutions. The Postman environment contains the environment variables used by the Postman collections to get tokens and establish WebSocket connections to the servers. This article also demonstrates how to fork these Postman items to a local workspace and how to set the environment variables to connect to different Refintiv Real-Time solutions.

# References

1. Asati, A., 2022. What is web socket and how it is different from the HTTP? - GeeksforGeeks. [online] GeeksforGeeks. Available at: <https://www.geeksforgeeks.org/what-is-web-socket-and-how-it-is-different-from-the-http/> [Accessed 20 July 2022].
2. Bal, G., 2018. Contributing your data to Refinitiv | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/contributing-your-data-refinitiv> [Accessed 19 July 2022].
3. Bal, G., 2019. OAuth grant types in Refinitiv Data Platform | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/oauth-grant-types-in-refinitiv-data-platform> [Accessed 19 July 2022].
4. Bhattacharya, S., 2021. Postman Now Supports WebSocket APIs | Postman Blog. [online] Postman Blog. Available at: <https://blog.postman.com/postman-supports-websocket-apis/> [Accessed 19 July 2022].
5. Nalla, U., 2019. Contributing Data to Refinitiv Real-Time using the WebSocket API | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/contributing-data-trep-using-websocket-api> [Accessed 19 July 2022].
6. Phuriphanvichai, J., 2022. Introduction to the Refinitiv Real-Time SDK Warm Standby Feature | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/introduction-to-the-refinitiv-real-time-sdk-warm-standby-feature> [Accessed 20 July 2022].
7. Developers.refinitiv.com. n.d. Refinitiv WebSocket API | Refinitiv Developers. [online] Available at: <https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api> [Accessed 19 July 2022].
8. Waeosri, W., 2017. How to implement RKD JSON application with Python chapter 1: the basic | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/how-to-implement-trkd-json-application-with-python-chapter-1-basic> [Accessed 19 July 2022].
9. Waeosri, W., 2019. Contributing your data to Refinitiv with WebSocket API and Refinitiv Real-Time Distribution System | Refinitiv Developers. [online] Developers.refinitiv.com. Available at: <https://developers.refinitiv.com/en/article-catalog/article/contributing-your-data-refinitiv-elektron-websocket-api-refinitiv> [Accessed 19 July 2022].
10. En.wikipedia.org. 2022. WebSocket - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/WebSocket> [Accessed 20 July 2022].