Last update | Dec 2023 |
Environment | Any |
Language | Any HTTP is supported |
Compilers | None |
Prerequisites | DSS login, internet access, REST API Tutorial 3 |
Source code | Below |
Please follow the REST API tutorial 3, which explains the workflow, before going through this one.
This tutorial explains how to:
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 EoD data we set a value of ElektronTimeseries. The preceding and following tutorials show other possibilities.
https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/GetValidContentFieldTypes(ReportTemplateType=DataScope.Select.Api.Extractions.ReportTemplates.ReportTemplateTypes'ElektronTimeseries')
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
Content-Type: application/json; charset=utf-8
Body:
There are more than 100 values in the response. Here is the beginning of the response:
{
"@odata.context": "https://selectapi.datascope.refinitiv.com/RestApi/v1/$metadata#ContentFieldTypes",
"value": [
{
"Code": "ETS.Advancing Issues",
"Name": "Advancing Issues",
"Description": "Number of issues which have advanced today",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Advancing Volume",
"Name": "Advancing Volume",
"Description": "Accumulated volume of issues that have advanced today",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Alternate Close",
"Name": "Alternate Close",
"Description": "Used to denote a secondary close price for a particular instrument",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Ask",
"Name": "Ask",
"Description": "Instrument's last ask price for the trading day",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Ask High",
"Name": "Ask High",
"Description": "Highest value of recorded ask orders.",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Ask Yield",
"Name": "Ask Yield",
"Description": "Current or Best Ask Yield or Secondary Active Yield field.",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Asset ID",
"Name": "Asset ID",
"Description": "Unique system-assigned identifier for the instrument",
"FormatType": "Text",
"FieldGroup": " "
},
This goes on with all the other available fields. Here is the last part:
{
"Code": "ETS.VWAP",
"Name": "VWAP",
"Description": "Volume Weighted Average Price",
"FormatType": "Number",
"FieldGroup": " "
},
{
"Code": "ETS.Wertpapier",
"Name": "Wertpapier",
"Description": "Issue-level code used for identifying instruments in Germany",
"FormatType": "Text",
"FieldGroup": " "
},
{
"Code": "ETS.Yield",
"Name": "Yield",
"Description": "For equities, this is the dividend per share expressed as a percentage of the price. For bonds, this is the current or simple yield i.e., the interest expressed as a percentage of the price",
"FormatType": "Number",
"FieldGroup": " "
}
]
}
https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw
Method: POST
Headers:
The body of the request must mention it is an extraction request. It contains several parts:
Prefer: respond-async
Content-Type: application/json
Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061
Body:
{
"ExtractionRequest": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.ElektronTimeseriesExtractionRequest",
"ContentFieldNames": [
"Instrument ID",
"Open",
"High",
"Low",
"Last",
"Volume",
"VWAP",
"Number of Price Moves",
"Trade Date"
],
"IdentifierList": {
"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
"InstrumentIdentifiers": [
{ "Identifier": "CARR.PA", "IdentifierType": "Ric" }
]
},
"Condition": {
"ReportDateRangeType": "Range",
"QueryStartDate": "1996-01-01",
"QueryEndDate": "2016-11-01"
}
}
}
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.
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://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRawResult(ExtractionId='0x057dc14e379b2f86')
Method: GET
Headers:
Prefer: respond-async
Content-Type: application/json
Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061
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.
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://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults('0x057dc14e379b2f86')/$value
Method: GET
Headers:
Prefer: respond-async
Content-Type: Accept-Encoding: gzip, deflate
Authorization: Token F0ABE9A3FFF2E02E10AE2765ED872C59B8CC3B40EBB61B30E295E71DE31C254B8648DB9434C2DF9299FDC668AA123501F322D99D45C8B93438063C912BC936C7B87062B0CF812138863F5D836A7B31A32DCA67EF07B3B50B2FC4978DF6F76784FDF35FCB523A8430DA93613BC5730CDC310D4D241718F9FC3F2E55465A24957CC287BDEC79046B31AD642606275AEAD76318CB221BD843348E1483670DA13968D8A242AAFCF9E13E23240C905AE46DED9EDCA9BB316B4C5C767B18DB2EA7ADD100817ADF059D01394BC6375BECAF6138C25DBA57577F0061
Content-Encoding: gzip
Content-Type: text/plain
Body:
Here is the beginning of the response content:
Instrument ID,Open,High,Low,Last,Volume,VWAP,Number of Price Moves,Trade Date
CARR.PA,2986,3030,2986,3017,28277,,,1996/01/02
CARR.PA,3050,3087,3035,3076,47323,,,1996/01/03
CARR.PA,3069,3141,3065,3129,59817,,,1996/01/04
CARR.PA,3067,3110,3056,3086,63216,,,1996/01/05
CARR.PA,3099,3125,3090,3099,20808,,,1996/01/08
CARR.PA,3108,3119,3100,3109,30141,,,1996/01/09
CARR.PA,3091,3125,3091,3120,28216,,,1996/01/10
CARR.PA,3109,3140,3105,3129,15204,,,1996/01/11
CARR.PA,3136,3175,3136,3163,39944,,,1996/01/12
Here is the end of the response content:
CARR.PA,23.08,23.185,23,23.055,1882751,23.087,4987,2016/10/17
CARR.PA,23.135,23.63,23.1,23.47,3746159,23.389,8886,2016/10/18
CARR.PA,24.1,24.84,23.665,24.57,7733197,24.317,20456,2016/10/19
CARR.PA,24.695,24.79,24.17,24.355,3693262,24.393,10185,2016/10/20
CARR.PA,24.425,24.475,24.165,24.315,2115738,24.298,6507,2016/10/21
CARR.PA,24.405,24.46,24.26,24.28,1791156,24.332,5205,2016/10/24
CARR.PA,24.35,24.435,24.04,24.28,2314436,24.246,7234,2016/10/25
CARR.PA,24.29,24.335,23.995,24.135,1940424,24.115,5894,2016/10/26
CARR.PA,24.085,24.245,23.96,24.155,1732727,24.12,6072,2016/10/27
CARR.PA,23.99,24.125,23.74,24.125,2226302,23.953,7221,2016/10/28
CARR.PA,24.025,24.065,23.805,23.895,1980502,23.887,4595,2016/10/31
CARR.PA,23.93,24.02,23.64,23.745,1899220,23.804,5585,2016/11/01