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 4: On Demand tick data extraction

Last update February 2020
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 previous tutorial, which explains the workflow, before going through this one.

This tutorial explains how to retrieve historical tick data, also called time and sales data, with an On Demand extraction request, using the following steps:

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

 

Table of contents

 

Get available field list for tick 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 tick data we set a value of TickHistoryTimeAndSales. The following tutorials show other possibilities.

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

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 tick 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:

There are more than 300 values in the response. Here is the beginning of the response:

{
  "@odata.context": "https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ContentFieldTypes",
  "value": [
    {
      "Code": "THT.Auction - Exchange Time",
      "Name": "Auction - Exchange Time",
      "Description": "Exchange supplied exchange time (Local or GMT depending on the exchange).",
      "FormatType": "Text",
      "FieldGroup": "Auction"
    },
    {
      "Code": "THT.Auction - Price",
      "Name": "Auction - Price",
      "Description": "Auction Price.",
      "FormatType": "Number",
      "FieldGroup": "Auction"
    },
    {
      "Code": "THT.Auction - Qualifiers",
      "Name": "Auction - Qualifiers",
      "Description": "Trade qualifiers or market condition indicator; See Qualifiers for more details.",
      "FormatType": "Text",
      "FieldGroup": "Auction"
    },
    {
      "Code": "THT.Auction - Sequence Number",
      "Name": "Auction - Sequence Number",
      "Description": "An exchange derived sequence number associated with the auction (applicable to US markets).",
      "FormatType": "Number",
      "FieldGroup": "Auction"
    },
    {
      "Code": "THT.Auction - Volume",
      "Name": "Auction - Volume",
      "Description": "Auction Volume.",
      "FormatType": "Number",
      "FieldGroup": "Auction"
    },

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

    {
      "Code": "THT.Trade - Volume",
      "Name": "Trade - Volume",
      "Description": "Last traded volume",
      "FormatType": "Number",
      "FieldGroup": "Trade"
    },
    {
      "Code": "THT.Trade - Weak Market",
      "Name": "Trade - Weak Market",
      "Description": "Market weakness",
      "FormatType": "Number",
      "FieldGroup": "Trade"
    },
    {
      "Code": "THT.Trade - Yield",
      "Name": "Trade - Yield",
      "Description": "An update to indicate Dividend Yield as adjusted by the last trade or closing price",
      "FormatType": "Number",
      "FieldGroup": "Trade"
    }
  ]
}

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

The group classifies fields by record type (auctions, corrections, market conditions, quotes and trades). It is preferable not to mix record types in a request.

Choose the field names you want. In the next step we will make a request for trade data, using a small set of these data field names.

 

Request tick 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 TickHistoryTimeAndSalesExtractionRequest. The 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 the date range for the request.
    {
      "ExtractionRequest": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.TickHistoryTimeAndSalesExtractionRequest",
        "ContentFieldNames": [
          "Trade - Price",
          "Trade - Volume",
          "Trade - Exchange Time",
        ],
        "IdentifierList": {
          "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",  
          "InstrumentIdentifiers": [
            { "Identifier": "CARR.PA", "IdentifierType": "Ric" }
          ]
        },
        "Condition": {
          "MessageTimeStampIn": "GmtUtc",
          "ApplyCorrectionsAndCancellations": false,
          "ReportDateRangeType": "Range",
          "QueryStartDate": "2016-09-29T00:00:00.000Z",
          "QueryEndDate": "2016-09-29T12:00:00.000Z",
          "DisplaySourceRIC": true
        }
      }
    }

     

    Request tick data - HTTP response

    The possible responses are described in detail the previous tutorial.

    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='0x05a64ba76a4b3036')

    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 value used as parameter in the URL:

    https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/RawExtractionResults('0x05a64ba76a4b3036')/$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:

    Here is the beginning of the response content, which for the above query contains more than 2000 lines:

    #RIC,Alias Underlying RIC,Domain,Date-Time,GMT Offset,Type,Price,Volume,Exch Time
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,63,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,64,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,27,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,2115,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,21,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,21,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.663334842Z,+2,Trade,23.25,11,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.664006387Z,+2,Trade,23.25,61,07:00:11.033000000
    CARR.PA,,Market Price,2016-09-29T07:00:11.664006387Z,+2,Trade,23.25,235,07:00:11.033000000

    Here is the end of the response content:

    CARR.PA,,Market Price,2016-09-29T09:58:40.317390181Z,+2,Trade,23.315,106,09:58:40.270000000
    CARR.PA,,Market Price,2016-09-29T09:59:19.166144512Z,+2,Trade,23.31,291,09:59:19.118000000
    CARR.PA,,Market Price,2016-09-29T09:59:38.569569939Z,+2,Trade,23.31,104,09:59:38.522000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.561625634Z,+2,Trade,23.305,88,09:59:59.499000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.589593409Z,+2,Trade,23.305,200,09:59:59.530000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.591582124Z,+2,Trade,23.31,267,09:59:59.530000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.591582124Z,+2,Trade,23.31,154,09:59:59.530000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.591582124Z,+2,Trade,23.31,275,09:59:59.530000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.601791962Z,+2,Trade,23.305,146,09:59:59.543000000
    CARR.PA,,Market Price,2016-09-29T09:59:59.637818164Z,+2,Trade,23.305,88,09:59:59.580000000

     

    Tutorial Group: 
    REST API Tutorials