/Extractions/InstrumentListImportFromBytes Information

Refinitiv customer support recommended me to use /Extractions/InstrumentListImportFromBytes. I cannot find much information in the REST API Reference tree or in the Q&A Forum.

It would be great if you could please provide me with information about what the API does and examples for the input and output.

These are the steps I am trying to follow in order to extract EOD pricing data using an Underling RIC for Futures and Options:

  1. Use DSS GUI to search for Futures and Options using Underlying RIC
  2. Create a CSV or XML file
  3. Refer to the REST API Reference Tree, there is the /Extractions/InstrumentListImportFromBytes endpoint which can import an instrument list from an XML or CSV file.


Best Answer

  • Gurpreet
    Gurpreet admin
    Answer ✓

    Hello @ellen.drexler,

    You can read the brief description of this endpoint in the REST API help. To use it, do the following steps:

    1. Read the CSV file into a string

    2. Base64 encode the string bytes

    3. Post this to the DSS

    Here is the sample file in the format (IdentifierType, Identifier):

    RIC,IBM
    RIC,GE
    RIC,TD
    RIC,T
    RIC,SPX
    RIC,PSA.TO
    RIC,MSFT.O

    and the code required to upload it to the server:

    url = 'https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/InstrumentListImportFromBytes';

    with open(fileName, 'r') as f:
    fstr = f.read()
    # convert string to Base64 encoded bytes
    b64str = base64.b64encode(fstr.encode()).decode()

    pBody = {
    'FileBytes': b64str,
    'Settings': {
    'ImportCreatedUserInstrumentsIntoList': True,
    'PredefinedAction': 'Add',
    'AllowDuplicateInstruments': True,
    'PredefinedName': 'ImportedFromAPI',
    'ImportUserInstruments': True
    },
    'FileName': fileName
    }

    resp = requests.post(url, data = json.dumps(pBody), headers = hdrs)

Answers