LSEG Data Library for .NET

Delivery.EndpointRequest object

This object defines the EndpointRequest with a url and other parameters.

Syntax

Delivery.EndpointRequest.Definition()

Delivery.EndpointRequest.Definition(string endpointUrl)

Delivery.EndpointRequest.Definition(Uri endpointUrl)

Delivery.EndpointRequest.Definition(ISession session, string api, string endpoint)

Parameters

Value Description
session The specific session. Eg: platform, desktop
api API stanza representing the data request. Eg: data.historical-pricing
endpointUrl The specific endpoint within the API. Eg: interday-summaries

Methods

Url(string url)

The Url represents the address of the endpoint.

Uri(Uri uri)

The Uri represents the address of the endpoint.

Method(EndpointRequest.Method method)

Defines the method of the request. Valid methods are: GET, POST, PUT and DELETE. Default: GET

QueryParameter(string key, string value)

Apply the specified key/value pair as a Query parameter to the URL.
Multiple calls to the same 'key' will be additive.

For example, multiple calls to add a 'Universe' parameter will create this: "Universe=AAPL.O,IBM.N".

BodyParameter(string key, string value)

BodyParameter(string key, int value)

BodyParameter(string key, double value)

BodyParameter(string key, bool value)

Apply the key/value pair to the Body of the URL request.

Only applies to simple 'key: value' elements at the root level of the message body.

More complex objects should use the BodyParameters(json) interface.

Multiple calls to the same 'key' will replace the value applied within the body.

HeaderParameter(string key, string value)

Apply the key/value pair to the Header section of the URL request.

Multiple calls to the same 'key' will be additive.

For example, multiple calls to add an 'Accept' parameter can look like this: "Accept: application/json, image/*".

PathParameter(string key, string value)

PathParameter(string value)

Apply the key/value pair to the path template within the URL request.

The URL will need to contain a path template containing the 'key'.

For example, "/dataContent/version1/analytics/{year}/{month}/{day}/prices".

The 'key' values defined in this template are 'year', 'month' and 'day.

Using PathParameter('year', 2019) will result in: '/dataContent/version1/analytics/2019/{month}/{day}/prices'.

BodyParameters(JObject parameters, bool merge = false)

Apply the JSON object to the body of the request.

By default, the parameters will overwrite any previous settings.

Optionally, the supplied parameters can be merged with the current body parameters settings.

Closure(object closure)

Optionally, include a user-defined Closure to match specific requests and responses.

The possible values for the EndpointRequest.Method:

Name Value
Method.GET 'GET'
Method.POST 'POST'
Method.PUT 'PUT'
Method.DELETE 'DELETE'

Returned value

EndpointRequestDefinition object.

Usage

The following example demonstrates how to create an endpoint request definition and request data:

var symbolLookupEndpoint = "https://api.refinitiv.com/discovery/symbology/v1/lookup";

var symbolRequest = new JObject()
{
    ["from"] = new JArray()
    {
        new JObject()
        {
            ["identifierTypes"] = new JArray("ExchangeTicker"),
            ["values"] = new JArray("IBM")
        }
    },
    ["to"] = new JArray()
    {
        new JObject() { ["identifierTypes"] = new JArray("RIC") }
    },
    ["type"] = "auto"
 };

  var response = EndpointRequest.Definition(symbolLookupEndpoint)
                                .Method(EndpointRequest.Method.POST)
                                .BodyParameters(symbolRequest)
                                .GetData();

The following example demonstrates how to retrieve interday and intraday data using the request definition.

For this specific examples the URI and its parameters are provided as a string to the definition.

var intradayEndpoint = "https://api.refinitiv.com/data/historical-pricing/v1/views/intraday-summaries/EUR=?interval=PT1H";
var interdayEndpoint = "https://api.refinitiv.com/data/historical-pricing/v1/views/interday-summaries";

using (ISession session = Sessions.GetSession())
{
    if (session.Open() == Session.State.Opened)
    {
        // Intraday Summaries - single instrument
        var response = EndpointRequest.Definition(intradayEndpoint).GetData();

        // Single Interday Summary - multiple instruments
        response = EndpointRequest.Definition(interdayEndpoint)
                                  .Method(EndpointRequest.Method.POST)
                                  .BodyParameters(new JObject()
                                  {
                                      ["fields"] = new JArray("BID", "ASK"),
                                      ["universe"] = new JArray("EUR=", "CAD=", "CHF="),
                                      ["end"] = "2022-01-01"
                                  })
                                  .GetData();
    }
}