Giter VIP home page Giter VIP logo

websocket-api's Introduction

Websocket API for Pricing Streaming and Real-Time Services

This API consists of a protocol specification. Also included is a set of example programs used to illustrate implementation of the protocol to make websocket connections to Refinitiv Real-Time Distribution Systems, and, to Refinitiv Real-Time -- Optimized (RTO). RTO examples authenticate via Refinitiv Data Platform (RDP). These examples are built using certain widely available Websocket frameworks and follow the protocol specification to demonstrate how to setup a websocket connection and use message constructs to receive Refinitiv Real-Time content. This API is governed by the same Apache 2 open source license as defined in the LICENSE.md file.

Example Code Disclaimer: ALL EXAMPLE CODE IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS FOR ILLUSTRATIVE PURPOSES ONLY. REFINITIV MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF EXAMPLE CODE, OR THE INFORMATION, CONTENT OR MATERIALS USED IN CONNECTION WITH EXAMPLE CODE. YOU EXPRESSLY AGREE THAT YOUR USE OF EXAMPLE CODE IS AT YOUR SOLE RISK

What's New

This release introduces oAuthClientCredentials authentication in Early Access in the Refinitiv Real-Time - Optimized (RTO) examples. A new RTO example written in Go has been added with support for oAuthClientCredentials. Please note that oAuthClientCredentials authentication method is available for preview only with ability to obtain Service Account credentials and use it, forthcoming.

Refinitiv Real-Time Distribution System Examples

These examples demonstrate the following usage:

  • Connecting, logging in, and requesting a single item
  • Requesting multiple items with a view in one message via a Batch Request
  • Posting content to an item
  • Logging in via Authentication
  • Monitoring connection health via Ping messages

The examples are found under the Applications/Examples folder. Examples are provided in the following languages:

  • C#
  • Java
  • Python
  • Perl
  • Node.js
  • Go
  • R
  • Ruby

More details for each example are included in a README.md file in its respective folder.

Refinitiv Real-Time - Optimized Examples

These are examples written in Python, CSharp, Go and Java that demonstrate consuming content from Refinitiv Real-Time - Optimized (RTO).

The examples are found in the Applications/Examples/RDP folder with language specific sub-folders. More details are included in a README.md file in each example folder.

  • Authenticating via RDP, Connecting to a Refinitiv Real-Time service available in RTO, and requesting a single item; examples handle session management or abiltiy to re-authenticate to renew authentication tokens
  • Discover which RTO endpoint to connect to by making a service discovery request to RDP and using this information to connect to RTO to receive Real-Time content.

IMPORTANT NOTE: When specifying a 'region' as input to RDP Service Discovery applications, please consult [RTO documentation available on Refinitiv Developer Community] (https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api/documentation) for a valid list of available regions. Default has been changed to "us-east-1" for region in sample applications starting with tag WSA-1.1.7.

Contributing

In the event you would like to contribute to this repository, it is required that you read and sign the following:

Please email a signed and scanned copy to [email protected]. If you require that a signed agreement has to be physically mailed to us, please email the request for a mailing address and we will get back to you on where you can send the signed documents.

Documentation for the WebSocket API and a Question & Answer forum are available at the WebSocket API Section of the Refinitiv Developer Community.

Support SLA

Issues raised via GitHub will be addressed in a best-effort manner. For broad questions regarding Websocket API, please refer to documentation and Q&A forum on Developer Community which is supported by an existing active community of API users.

websocket-api's People

Contributors

apjanke avatar ayurov2 avatar brettjbush avatar dmykhailishen avatar emmanuelcanaan avatar fogol avatar jimcarroll64 avatar soranat avatar timvanepps-tr avatar vlevendel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

websocket-api's Issues

websocket-client version for RDP Python examples

The readme.md shows that it requires the websocket-client must be version 0.49 or greater.

However, I am using 0.57.0 and it doesn't work with the market_price_rdpgw_service_discovery.py.

After upgrading to websocket-client 1.1.0, it works fine. Please update the readme.md.

Incomplete RTO Go README file instruction

Hi Team,

I have followed the steps in /RDP/go/README.md, but I cannot run the market_price_rdpgw_client_cred_auth.go example. It always returns "no required module provides package github.com/gorilla/websocket" message.

go version go1.17.12 linux/amd64

Example Logs:

[root@ddef5e35bfd4 go]# go get github.com/gorilla/websocket
go: downloading github.com/gorilla/websocket v1.5.0

[root@ddef5e35bfd4 go]# go run market_price_rdpgw_client_cred_auth.go --clientid $RTO_CLIENTID_V2_1 --clientsecret $RTO_CLIENTSECRET_1

market_price_rdpgw_client_cred_auth.go:28:2: no required module provides package github.com/gorilla/websocket: go.mod file not found in current directory or any parent directory; see 'go help modules'

According to my research, A go app first needs to be initialized with go mod init before we can use external modules. I tested it and the example works fine.

Example:

[root@ddef5e35bfd4 go]# go mod init myapp
go: creating new go.mod: module myapp
go: to add module requirements and sums:
        go mod tidy
[root@ddef5e35bfd4 go]# go get github.com/gorilla/websocket
go get: added github.com/gorilla/websocket v1.5.0

[root@ddef5e35bfd4 go]# go run market_price_rdpgw_client_cred_auth.go --clientid $RTO_CLIENTID_V2_1 --clientsecret $RTO_CLIENTSECRET_1
2022-09-12 11:16:32.262737 Sending authentication request...
2022-09-12 11:16:33.935777 RECEIVED:
{
  "access_token": "<access_token>",
  "expires_in": 7199,
  "token_type": "Bearer"
}
..

Best regards,

Wasin W.

Remove / reduce the confusion between username and MachineID

We are still getting customers who are using their username (e.g. corporate email address) for the --user parameter when running the examples - leading to frustration, time waste all around and a very poor introductory experience of Refinitiv.

This is despite Quickstarts, RTO guides and Welcome Emails etc mentioning that MachineID is required for programmatic access to data.

In view of this can we change the README and examples to mention MachineID. Ideally, even show a dummy machineID so that there remains no doubt.
e.g. in code
user = 'GE-A-001234545-1-1234' // Replace with your Machine ID

and on the README page:

--user REQUIRED. MachineID to use when authenticating to Refinitiv Data Platform.

OR even better change the parameter name to MachineID

Redirect from customer support team - case 11082530

Hi,

We are hitting an authentication issue when trying to integrate FX pricing API from our system, please find details below:

{
"error": {
"id": "1f1bb7bb-52e3-4372-ae55-947cd32d0478",
"code": "insufficient_scope",
"message": "access denied. Scopes required to access the resource: [trapi.streaming.pricing.read]. Missing scopes: [trapi.streaming.pricing.read]",
"status": "Forbidden"
}
}

We had a call with the customer support team and they can't figure out this issue, please give us a help in an urgent manner since our business is currently blocked by this, thanks a lot.

Best Regards,
Robbin

Error when stop the Python WebSocket application with websocket-client version 1.2.1

The Python examples (market_price.py, market_price_rdpgw_service_discovery.py, etc.) show the error message when pressing Ctrl+C to stop the application. This issue occurs with the websocket-client library version 1.2.1. The websocket-client library version 1.1.0 works fine without any error messages.

The market_price_rdpgw_service_discovery.py Example:
The websocket-client library version 1.2.1, running the application and pressing Ctrl+C after the application received an item refresh response message.

Closing the WebSocket connection for session1
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 407, in _callback
    callback(self, *args)
TypeError: _on_close() takes 2 positional arguments but 4 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 369, in run_forever
    dispatcher.read(self.sock.sock, read, check)
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 70, in read
    if not read_callback():
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 333, in read
    return teardown()
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 303, in teardown
    self._callback(self.on_close, close_status_code, close_reason)
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 412, in _callback
    self.on_error(self, e)
  File "market_price_rdpgw_service_discovery.py", line 175, in _on_error
    print(error + " for " + self.session_name)
TypeError: unsupported operand type(s) for +: 'TypeError' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 407, in _callback
    callback(self, *args)
  File "market_price_rdpgw_service_discovery.py", line 175, in _on_error
    print(error + " for " + self.session_name)
TypeError: unsupported operand type(s) for +: 'TypeError' and 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 371, in run_forever
    self._callback(self.on_error, e)
  File "C:\drive_d\compilers\Miniconda3\envs\testws\lib\site-packages\websocket\_app.py", line 412, in _callback
    self.on_error(self, e)
  File "market_price_rdpgw_service_discovery.py", line 175, in _on_error
    print(error + " for " + self.session_name)
TypeError: unsupported operand type(s) for +: 'TypeError' and 'str'

The websocket-client library version 1.1.0 does not show the error messages above.

The market_price.py Example:
The websocket-client library version 1.2.1 shows the following error message when closing the application.

on_close() takes 1 positional argument but 3 were given

The websocket-client library version 1.1.0 does not show this error message above.

backupHostList is not defined

Hi all,
Please note that the market_price_rdpgw_service_discovery.py uses an undefined variable backupHostList .
Running the example generates the following error:
Traceback (most recent call last):
File "C:\Refinitiv\websocket-api-master\Applications\Examples\RDP\python\market_price_rdpgw_service_discovery.py", line 555, in
if not query_service_discovery():
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Refinitiv\websocket-api-master\Applications\Examples\RDP\python\market_price_rdpgw_service_discovery.py", line 257, in query_service_discovery
backupHostList.append(response_json['services'][index]['endpoint'] + ":" +
^^^^^^^^^^^^^^
NameError: name 'backupHostList' is not defined

Suggest to add handling for on websocket connection disconnected

In https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/EDP/java/MarketPriceEdpGwAuthentication.java

When the consumer WebSocket connection to ERT in Cloud gets disconnected by the ERT in Cloud, the sample application does not print out any information on the output and the process to refresh the token is still repeating.
So it is quite confusing.
Suggest to impletement onDisconnected() and just terminate the app.
Or even better, re-do the whole authentication and item request again.

Refinitiv organization/company name in Contributor License Agreement?

Hi folks,

In the Contributor License Agreements in this repo, as of 1/7/2020, the "Us" is just described as "Websocket API". That's not a legal entity, is it? And it's not very descriptive – there's a lot of Websocket APIs out there. Shouldn't the "Us" be something like "Refinitiv, Inc., a U.S. corporation incorporated under New York law" or "The Refinitiv Elektron Messaging API Websocket API", and then include some corporate contact info like an address somewhere in the agreement? (I see a URL there, but URLs aren't very permanent or official-like, right?)

Batch request - how to specify the service

Hello,

I'm trying to make a batch request like in the doc, but cannot find a way to specify the service :

{
"ID":2,
"Key":{
 "Name":[
  "TRI.N",
  "IBM.N",
  "T.N"
]}
}

I tried

{
"ID":2,
"Key":{
 "Name":[
  "TRI.N",
  "IBM.N",
  "T.N"
], "Service": "SRV"}
}

and

{
"ID":2,
"Key":{
 "Name":[
  "TRI.N",
  "IBM.N",
  "T.N"
], "Service": ["SRV", "SRV", "SRV"]}
}

But it does not seem to work

If I don't specify it, I believe the server tries to look for those keys in another service

Is there another way?

Thank you

Go market_price examples gives 403

Hey all.

I have downloaded bunch of examples as to experiment on connecting to our internal trep servers.

I have tested with Java and Python that those two work fine without any issues.

However, when I try using golang example, I am getting 403 Forbidden, even tho the same parameters are being used.
I suspect some issues with how gorilla websockets are handling the handshake.

Given that its no longer supported, the examples for go should be updated, to fix the error and use a supported framework.

"beta" version of OAuth2 endpoint?

Some of the code in these examples has "beta1" in the URL for the OAuth2 endpoint.

Is this expected? Is there a production/release-to-master/non-beta version of this service endpoint available? Should users be hitting a beta authentication service like this?

$ grep -r beta *
Applications/Examples/EDP/python/market_price_edpgw_authentication.py:auth_url = 'https://api.refinitiv.com:443/auth/oauth2/beta1/token'
Applications/Examples/EDP/python/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/python/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/python/market_price_edpgw_service_discovery.py:auth_url = 'https://api.refinitiv.com:443/auth/oauth2/beta1/token'
Applications/Examples/EDP/java/MarketPriceEdpGwServiceDiscovery.java:    public static String authUrl = "https://api.refinitiv.com:443/auth/oauth2/beta1/token";
Applications/Examples/EDP/java/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/java/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/java/MarketPriceEdpGwAuthentication.java:    public static String authUrl = "https://api.refinitiv.com:443/auth/oauth2/beta1/token";
Applications/Examples/EDP/CSharp/MarketPriceEdpGwServiceDiscoveryExample/MarketPriceEdpGwServiceDiscoveryExample.csproj:    <PackageReference Include="Newtonsoft.Json" Version="12.0.1-beta1" />
Applications/Examples/EDP/CSharp/MarketPriceEdpGwServiceDiscoveryExample/MarketPriceEdpGwServiceDiscoveryExample.cs:        /// https://api.refinitiv.com:443/auth/oauth2/beta1/token is used.</summary>
Applications/Examples/EDP/CSharp/MarketPriceEdpGwServiceDiscoveryExample/MarketPriceEdpGwServiceDiscoveryExample.cs:        private static string _authUrl = "https://api.refinitiv.com:443/auth/oauth2/beta1/token";
Applications/Examples/EDP/CSharp/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/CSharp/README.md:`--auth_url`      | OPTIONAL. URL of the EDP Gateway. Defaults to https://api.refinitiv.com:443/auth/oauth2/beta1/token.
Applications/Examples/EDP/CSharp/MarketPriceEdpGwAuthenticationExample/MarketPriceEdpGwAuthenticationExample.cs:        /// https://api.refinitiv.com:443/auth/oauth2/beta1/token is used.</summary>
Applications/Examples/EDP/CSharp/MarketPriceEdpGwAuthenticationExample/MarketPriceEdpGwAuthenticationExample.cs:        private string _authUrl = "https://api.refinitiv.com:443/auth/oauth2/beta1/token";
Applications/Examples/EDP/CSharp/MarketPriceEdpGwAuthenticationExample/MarketPriceEdpGwAuthenticationExample.csproj:    <PackageReference Include="Newtonsoft.Json" Version="12.0.1-beta1" />
$

RTO C# MarketPriceRdpGwClientCredAuthExample shows "KeyNotFoundException: The given key 'Session1' was not present in the dictionary."

Hi team,

When I run the RTO C# MarketPriceRdpGwClientCredAuthExample using the Service Discovery feature, the example application throws the "System.Collections.Generic.KeyNotFoundException: The given key 'Session1' was not present in the dictionary." exception message and crashes:

Error Messages:

dotnet MarketPriceRdpGwClientCredAuthExample.dll --clientid $RTO_CLIENTID_V2_1 --clientsecret $RTO_CLIENTSECRET_1 
9/12/22 10:52:38 AM Sending authentication request to https://api.refinitiv.com/auth/oauth2/v2/token
9/12/22 10:52:40 AM RECEIVED:
{
  "expires_in": 7199,
  "token_type": "Bearer",
  "access_token": "<access_token>"
}

9/12/22 10:52:41 AM Sending service discovery request to https://api.refinitiv.com/streaming/pricing/v1/?transport=websocket

System.Collections.Generic.KeyNotFoundException: The given key 'Session1' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at MarketPriceRdpGwServiceDiscoveryExample.MarketPriceRdpGwServiceDiscoveryExample.Run() in /opt/refinitiv/websocket-api/Applications/Examples/RDP/CSharp/MarketPriceRdpGwClientCredAuthExample/MarketPriceRdpGwClientCredAuthExample.cs:line 644

However, when I specify the --hostname argument, it works fine.

Example:

dotnet MarketPriceRdpGwClientCredAuthExample.dll --clientid $RTO_CLIENTID_V2_1 --clientsecret $RTO_CLIENTSECRET_1 --hostname ap-northeast-1-aws-1-sm.optimized-pricing-api.refinitiv.net

According to my observation, if I do not set the --hostname argument (use the Service Discovery), the following code statement is not executed.

 foreach (var host in _hosts)
                {
                    var webSocketSession = new WebSocketSession("Session" + (_webSocketSessions.Count + 1), host.Item1, host.Item2);
                    _webSocketSessions.Add(webSocketSession.Name, webSocketSession);
...

Best regards,

Wasin W.

Any plans to update C# projects to .Net 6?

Hi,

The RTSDK C# is now released with .NET Core 6.0 supported. However, the WebSocket C# projects still use older versions of the frameworks

  • WebSocket C# examples support Visual Studio 2015 (.Net framework 4.5.1, no cross-platform)
  • WebSocket C# examples support .Net core 3.1 (cross platform)

Do you have any plans to update them to up to dated .Net Core 6?

Streaming example with updates or repeated polling

It seems like it's a bit of a jump to get from the one-shot examples currently in this repo to a connection or session that stays open and either receives streaming data or repeatedly polls for refresh updates. In particular, the authentication token expires after about 5 minutes and requires refreshing. Maybe an example of how to do that could be added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.