Changing Date Format when requesting RDMS API in text/csv response?

lmorel
lmorel Newcomer
edited April 17 in RDMS

Hi,

We are retrieving curve data from RDMS Rest API (v1/v1/CurveValuesBatch resource).

When requesting a text/csv return, the date format (Forecast Date, ValueDate) is in American format:

Is there a way to request another date format directly from the API with a csv response? (for e.g: DD.MM.YYYY 00:00:00)

Thanks a lot,

Annotation 2025-04-16 162839.png

Answers

  • Hi @lmorel

    Based on the API documentation at https://<your-instance>.rdms.refinitiv.com/api/swagger/index.html (more detail can be found at https://developers.lseg.com/en/api-catalog/ldms/ldms/quickstart ), I cannot find any function to do so.

    Hoever, the code below can be used to convert datetime format

    import pandas as pd
    import io import requests
    import json

    url = "https://demo.rdms.refinitiv.com/api/v1/CurveValuesBatch"

    payload = json.dumps({
    "scenarioID": 0,
    "minForecastDate": "2022-04-10T01:09:38.985Z",
    "maxForecastDate": "2025-04-18T01:09:38.985Z",
    "resultTimezone": "UTC",
    "sortForecastsDateDescending": True,
    "sortValuesDateDescending": True,
    "curveRequests": [
    {
    "curveID": "100659"
    },
    {
    "curveID": "136552"
    }
    ]
    })
    headers = {
    'Authorization': 'apikey-v1 <your API key>',
    'Content-Type': 'application/json',
    'Accept': 'text/csv'
    }

    response = requests.request("POST", url, headers=headers, data=payload)

    data = response.text
    buffer = io.StringIO(data)

    df = pd.read_csv(filepath_or_buffer = buffer) df['ForecastDate'] = pd.to_datetime(df['ForecastDate'], format='%m/%d/%Y %H:%M:%S %p +00:00')
    df['ValueDate'] = pd.to_datetime(df['ValueDate'], format='%m/%d/%Y %H:%M:%S %p +00:00')
    df

    image.png