For a deeper look into our DataScope Select SOAP API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
1 0 1 2

Search by File Code in FuturesAndOptionsSearch

Hi,

I want to use the FuturesAndOptionsSearch to get all RICs within a FileCode without creating Instrument Usage on my DSS ID. Can I search by FIle Code with the API and if yes will my results be limited/truncated to 5000 lines? If the results will be limited, is there a workaround to request batches of 5000 results one after the other?

I have tried to post the following, obviously without success:

Request:

{ "SearchRequest": { "FileCodes": "7155", "CurrencyCodes": null, "ExchangeCodes": null, "IdentifierType": null, "Identifier": null, "PreferredIdentifierType": "Ric" } }

Respose:

{ "error": { "message": "Malformed request payload: Invalid cast exception for property FileCodes: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.List`1[System.String]'." } }

Thanks in advance any comments.

Greg

dss-rest-apidatascope-selectdsssearch
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
38.1k 71 35 53

FileCodes property is an array of string, not a string. Therefore, the request must looks like:

{  
   "SearchRequest":{  
      "FileCodes":[  
         "7155"
      ],
      "CurrencyCodes":null,
      "ExchangeCodes":null,
      "IdentifierType":null,
      "Identifier":null,
      "PreferredIdentifierType":"Ric"
   }
} 

The number of results is limited by maxpagesize. The default maxpagesize is 250.

If there is a next page, the last property in the response will be "@odata.nextlink" field.

        {
            "Identifier": "UNGB231802400.U",
...
        }
    ],
    "@odata.nextlink": "https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/FuturesAndOptionsSearch?$skiptoken='MjUw'"

To get the next page, you need to use another POST request with the URL in "@odata.nextlink" field with the same SearchRequest in the payload.

However, you can change the number of entries returned in the response by specifying odata.maxpagesize in the Prefer header.

Prefer: odata.maxpagesize=500; respond-async

For more information regarding maxpagesize, please refer to this question

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
9.5k 10 5 7

Hello

You need to add "[" and "]" around the value of "FileCodes" because its type is

IEnumerable<string> like the list of multiple strings as shown below:

{
    "SearchRequest": {
        "FileCodes": [
        "7155"
         ],
        "CurrencyCodes": null,
        "ExchangeCodes": null,
        "IdentifierType": null, 
        "Identifier": null, 
        "PreferredIdentifierType": "Ric" 
    }
}

The example result:

{  
"@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#Collection(ThomsonReuters.Dss.Api.Content.ValidatedInstrument)",  
"value": [  
   {  
	"Identifier": "TRGPA181904500.U",  
	"IdentifierType": "Ric",  
	"Source": "OPQ",  
	"Key": "VjF8MHgwMDEwMGIwMDEyZTBlOWM0fDB4MDAxMDBiMDAxMmUwZTg1YXxPUFF8RFZRVXxPUFR8fER8fFRSR1BBMTgxOTA0NTAwLlV8NzE1NQ",  
	"Description": "TRGP Jan9 45.0 C",  
	"InstrumentType": "DerivativeQuote",  
	"Status": "Valid"  
},
...
],
"@odata.nextlink": "https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/FuturesAndOptionsSearch?$skiptoken='MjUw'"
}

You can find out each parameter's type and the example http request(JSON Model) in API Reference Tree of FuturesAndOptionsSearch

For the API, please refer to

.Net SDK Tutorial 12: Search for Future or Option

DSS2SearchFuture.java in Java Code Example

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
1 0 1 2

Thank You! Works perfectly. One additional question is what maximum number can I specify in the parameter odata.maxpagesize=??? I have tried even with 100000 and it works. Did I get lucky or will such requests always work? I noticed it took quite long.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
13.7k 26 8 12

@Gregor, I don't know if there is a max number for odata.maxpagesize, but please note the following from the help page on server driven paging:

Server-driven paging ensures that the quantity of data that is returned by a URI does not overwhelm DataScope Select REST API servers or the user agent application.

[...]

The DataScope Select REST API conforms to OData server driven paging specifications.

[...]

The page size default is 250 records for endpoints that support paging. This value can be customized although the DataScope REST API is not required to honor the requested page size. You should always code the user agent to account for the nextlink.

In other words: we recommend:

  • To avoid setting large values for odata.maxpagesize. Setting a very large value will slow things down, as you noticed.
  • That client code accounts for the nextlink. This will avoid errors.
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea