Thomson Reuters Tick History (TRTH) - REST API

Close Menu
Expand All Collapse All
Introductory Tutorials Tutorials Introduction Video introduction to the TRTH REST API Programming without SDK Tutorial REST API Tutorials REST API Tutorials Introduction REST API Tutorial 1: Connecting to the server REST API Tutorial 2: Retrieving VBD files REST API Tutorial 3: On Demand data extraction workflow REST API Tutorial 4: On Demand tick data extraction REST API Tutorial 5: On Demand market depth extraction REST API Tutorial 6: On Demand intraday bars extraction REST API Tutorial 7: On Demand End of Day extraction REST API Tutorial 8: On Demand raw data extraction REST API Tutorial 9: On Demand corporate actions extraction REST API Tutorial 10: On Demand Histo Reference extraction REST API Tutorial 11: On Demand extraction: instrument list REST API Tutorial 12: GUI control calls: immediate extract REST API Tutorial 13: Historical Search REST API Tutorial 14: Historical Criteria Search REST API Tutorial 15: Historical Chain Constituents Search REST API Tutorial 16: Search by Instrument REST API Tutorial 17: Search for an Equity REST API Tutorial 18: Search for a Future or Option .Net SDK Tutorials .Net SDK Tutorial 1: Connecting to the server .Net SDK Tutorial 2: Retrieving VBD files .Net SDK Tutorial 3: GUI control calls: List, report, sched .Net SDK Tutorial 4: GUI control calls: Validate, extraction .Net SDK Tutorial 5: On Demand extraction, file IO Google BigQuery Tutorials Introduction and environment set-up Data retrieval and tick filters Data analytics Query optimization

REST API Tutorial 6: On Demand intraday bars extraction

Last update November 2019
Environment Any
Language Any HTTP is supported
Compilers None
Prerequisites DSS login, internet access, REST API Tutorial 3
Source code Below

Tutorial purpose

Please follow the REST API tutorial 3, which explains the workflow, before going through this one.

This tutorial explains how to:

  • Retrieve the available field list from the server (optional).
  • Request intraday bars data from the server, using an on demand request.
  • Check the request status.
  • Retrieve the data.

 

Table of contents

 

Get available field list for intraday bars data - HTTP request

This step is optional. If you do not know what content field names are available, you can request a list of those available.

URL:

The available field set depends on the type of data you want to request. The data type must therefore be specified in the request, which is done by setting a report template type in the URL. As we want intraday bars data we set a value of TickHistoryIntradaySummaries. The preceding and following tutorials show other possibilities.

https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/GetValidContentFieldTypes(ReportTemplateType=ThomsonReuters.Dss.Api.Extractions.ReportTemplates.ReportTemplateTypes'TickHistoryIntradaySummaries')

Method:          GET

Headers:

Note: for all requests we need a user token, set in the header. The token was retrieved in Tutorial 1.

Prefer: respond-async
Content-Type: application/json
Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061



Get available field list for intraday bars data - HTTP response

If the token is valid, this is the response we get:

Status:                        200 OK

Relevant headers:

Content-Type: application/json; charset=utf-8

Body:

Here is the beginning of the response:

{
    "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ContentFieldTypes",
    "value": [
        {
            "Code": "THI.Close Ask",
            "Name": "Close Ask",
            "Description": "Last Ask price in the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Close Ask Yield",
            "Name": "Close Ask Yield",
            "Description": "Last Ask yield in the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Close Bid",
            "Name": "Close Bid",
            "Description": "Last Bid price in the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Close Bid Yield",
            "Name": "Close Bid Yield",
            "Description": "Last Bid yield in the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Close Discount Factor",
            "Name": "Close Discount Factor",
            "Description": "Last discount factor of the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        },

This goes on with all the other available fields. Here is the last part:

        {
            "Code": "THI.Open Zero Yield",
            "Name": "Open Zero Yield",
            "Description": "Opening zero yield of the day",
            "FormatType": "Number",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Sample Data",
            "Name": "Sample Data",
            "Description": "Sample data. For internal use only",
            "FormatType": "Text",
            "FieldGroup": " "
        },
        {
            "Code": "THI.Volume",
            "Name": "Volume",
            "Description": "Total traded volume over the interval",
            "FormatType": "Number",
            "FieldGroup": " "
        }
    ]
}

The result contains the field code, name, a description, field type (number, text, date) and group.

Choose the field names you want. In the next step we will make a request for intraday bars data, using these data fields.

 

 

Request intraday bars data - HTTP request

This is an On Demand extraction request.

    URL:

    https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRaw

    Method:          POST

    Headers:

    Prefer: respond-async
    Content-Type: application/json
    Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061

    Body:

    The body of the request must mention it is an extraction request. It contains several parts:

    • The type of extraction: as we want tick data we set a value of TickHistoryIntradaySummariesExtractionRequest. The preceding and following tutorials show other possibilities.
    • The list of field names: these were determined in the previous step of this tutorial.
    • The list of instrument identifiers, each one with its type. Below we define one instrument using a RIC.
    • The conditions: they include among others the bar interval, and the date range for the request.

      Possible bar intervals are: OneSecond, FiveSeconds, OneMinute, FiveMinutes, TenMinutes, FifteenMinutes, OneHour.
    {
      "ExtractionRequest": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryIntradaySummariesExtractionRequest",
        "ContentFieldNames": [
          "Close Ask",
          "Close Bid",
          "High",
          "High Ask",
          "High Bid",
          "Last",
          "Low",
          "Low Ask",
          "Low Bid",
          "No. Asks",
          "No. Bids",
          "No. Trades",
          "Open",
          "Open Ask",
          "Open Bid",
          "Volume"
        ],
        "IdentifierList": {
          "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",  
          "InstrumentIdentifiers": [
            { "Identifier": "CARR.PA", "IdentifierType": "Ric" }
          ],
          "ValidationOptions": null,
          "UseUserPreferencesForValidationOptions": false
        },
        "Condition": {
          "MessageTimeStampIn": "GmtUtc",
          "ReportDateRangeType": "Range",
          "QueryStartDate": "2016-09-29T00:00:00.000Z",
          "QueryEndDate": "2016-09-30T00:00:00.000Z",
          "SummaryInterval": "OneHour",
          "TimebarPersistence": true,
          "DisplaySourceRIC": true
        }
      }
    }

     

    Request intraday bar data - HTTP response

    The possible responses are described in detail the REST API tutorial 3.

    In a nutshell, the most likely outcome is a response with an HTTP status of 202 Accepted, and the header will contain a location URL. The next step is to check the request status by polling the location URL regularly until it returns a 200 OK.

    If the request is for a small amount of data, the response could have an HTTP status of 200 OK, and the body will contain a jobId and Notes. If the Notes contain the message: Processing completed successfully, we can proceed further. We skip the step where we check the request status, and go directly to the last step, which is to retrieve the data using the jobId.

    Other HTTP status codes can be encountered, follow this link for a full list with detailed explanations. It is strongly recommended that your code handle all possible status codes.

     

    Check request status - HTTP request

    Skip this step if the previous step returned an HTTP status of 200 OK.

    If the previous step returned an HTTP status of 202 Accepted, this step must be executed, and repeated in a polling loop until it returns an HTTP status of 200 OK.

    URL:

    This is the location URL, taken from the 202 response header received in the previous step.

    https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='0x057c7f4ef54b2f86')

    Method:          GET

    Headers:

    Prefer: respond-async
    Content-Type: application/json
    Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061

     

    Check request status - HTTP response

    If you receive an HTTP status 202 Accepted response (the same as in the previous step), it means the request has not yet completed. You must wait a bit and check the request status again.

    If you receive an HTTP status 200 OK response, the body will contain a jobId and Notes. If the Notes contain the message: Processing completed successfully, we can proceed further. We go to the last step, which is to retrieve the data using the jobId.

     

    Retrieve data - HTTP request

    It is mandatory to have received a 200 OK response with a JobID from a previous step before proceeding with this last step.

    URL:

    Note the jobId, used as parameter in the URL.

    https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults('0x057c7f4ef54b2f86')/$value

    Method:          GET

    Headers:

    Prefer: respond-async
    Content-Type: Accept-Encoding: gzip, deflate
    Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061

     

    Retrieve data - HTTP response

    We should get a response of this type:

    Status:                        200 OK

    Relevant headers:

    Content-Encoding: gzip
    Content-Type: text/plain

    Body:

    For a given time range, the result contains much less data than that of a tick or market depth data request, because bars summarize market activity.

    Here is the response content:

    #RIC,Alias Underlying RIC,Domain,Date-Time,GMT Offset,Type,Open,High,Low,Last,Volume,No. Trades,Open Bid,High Bid,Low Bid,Close Bid,No. Bids,Open Ask,High Ask,Low Ask,Close Ask,No. Asks
    CARR.PA,,Market Price,2016-09-28T22:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.065,24.83,22.995,23.03,0,23.07,23.105,21.855,23.045,0
    CARR.PA,,Market Price,2016-09-28T23:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.065,24.83,22.995,23.03,0,23.07,23.105,21.855,23.045,0
    CARR.PA,,Market Price,2016-09-29T00:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.065,24.83,22.995,23.03,0,23.07,23.105,21.855,23.045,0
    CARR.PA,,Market Price,2016-09-29T01:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.065,24.83,22.995,23.03,0,23.07,23.105,21.855,23.045,0
    CARR.PA,,Market Price,2016-09-29T02:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,22.96,22.96,22.96,22.96,1,23.1,23.1,23.1,23.1,1
    CARR.PA,,Market Price,2016-09-29T03:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,22.96,22.96,22.96,22.96,0,23.1,23.1,23.1,23.1,0
    CARR.PA,,Market Price,2016-09-29T04:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,22.96,22.96,22.96,22.96,0,23.1,23.1,23.1,23.1,0
    CARR.PA,,Market Price,2016-09-29T05:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23,23.045,23,23.045,5,23.1,23.1,23.1,23.1,5
    CARR.PA,,Market Price,2016-09-29T06:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23,23.045,23,23.045,23,23.1,23.1,23.1,23.1,21
    CARR.PA,,Market Price,2016-09-29T07:00:00.000000000Z,+2,Intraday 1Hour,23.25,23.465,23.25,23.445,542668,1564,24.42,24.42,23.25,23.44,7382,20.85,23.475,20.85,23.45,7794
    CARR.PA,,Market Price,2016-09-29T08:00:00.000000000Z,+2,Intraday 1Hour,23.445,23.45,23.36,23.37,241431,783,23.44,23.45,23.35,23.36,13054,23.45,23.46,23.36,23.37,12648
    CARR.PA,,Market Price,2016-09-29T09:00:00.000000000Z,+2,Intraday 1Hour,23.37,23.38,23.29,23.305,128333,550,23.36,23.38,23.28,23.305,8848,23.37,23.39,23.29,23.31,8379
    CARR.PA,,Market Price,2016-09-29T10:00:00.000000000Z,+2,Intraday 1Hour,23.305,23.335,23.235,23.26,109823,472,23.305,23.33,23.235,23.25,7081,23.31,23.34,23.245,23.255,6545
    CARR.PA,,Market Price,2016-09-29T11:00:00.000000000Z,+2,Intraday 1Hour,23.255,23.295,23.245,23.245,61004,251,23.25,23.29,23.24,23.24,4902,23.255,23.295,23.25,23.25,5984
    CARR.PA,,Market Price,2016-09-29T12:00:00.000000000Z,+2,Intraday 1Hour,23.25,23.255,23.135,23.15,113076,547,23.24,23.255,23.13,23.15,9180,23.25,23.26,23.14,23.155,9464
    CARR.PA,,Market Price,2016-09-29T13:00:00.000000000Z,+2,Intraday 1Hour,23.155,23.155,23.06,23.13,183534,739,23.15,23.155,23.055,23.125,10618,23.155,23.165,23.065,23.135,11276
    CARR.PA,,Market Price,2016-09-29T14:00:00.000000000Z,+2,Intraday 1Hour,23.125,23.16,23.005,23.02,206731,732,23.125,23.16,23,23.015,15241,23.135,23.17,23.01,23.02,18665
    CARR.PA,,Market Price,2016-09-29T15:00:00.000000000Z,+2,Intraday 1Hour,23.015,23.055,22.98,23.055,702673,873,23.015,25.32,22.98,23.055,6529,23.02,23.065,21.9,23.065,7379
    CARR.PA,,Market Price,2016-09-29T16:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0
    CARR.PA,,Market Price,2016-09-29T17:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0
    CARR.PA,,Market Price,2016-09-29T18:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0
    CARR.PA,,Market Price,2016-09-29T19:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0
    CARR.PA,,Market Price,2016-09-29T20:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0
    CARR.PA,,Market Price,2016-09-29T21:00:00.000000000Z,+2,Intraday 1Hour,,,,,,,23.015,25.32,22.98,23.055,0,23.02,23.065,21.9,23.065,0

     

    Tutorial Group: 
    REST API Tutorials