requestData for the funds API

In the python starter code for RDP the following can be used for the funds API:

EDP_version = "/v1"
base_URL = "https://api.refinitiv.com"
category_URL = "/data/funds"
endpoint_URL = "/assets"
RESOURCE_ENDPOINT = base_URL + category_URL + EDP_version + endpoint_URL
lipperID = "40003333"

requestData = {
"symbols": lipperID,
"properties": "names"
}

dResp = requests.get(RESOURCE_ENDPOINT, headers = {"Authorization": "Bearer " + accessToken}, params = requestPayload)



What kind of `requestData` should I use for prices/filter NAV, with start and end prices ? as follows:

https://api.refinitiv.com/data/funds/v1/assets?properties=prices[start:2023-01-09%3Bend:2023-01-10%3Bfilter:nav]&symbols=SPY.N,QQQ.N,FCNTX

I tried:

symbols = "SPY.N,FCNTX"
requestData = {
"symbols": symbols,
"properties": "prices",
"filter": "MID",
"start": "2018-02-01",
"end": "2018-05-05"
}

but that did not take into account start end or the filter

and

symbols = "SPY.N,FCNTX"
requestData = {
"symbols": symbols,
"properties": "prices[start:2023-01-09%3Bend:2023-01-10%3Bfilter:nav]",
"start": "2018-02-01",
"end": "2018-05-05"
}

which gave an error





Best Answer

  • kdayri
    Answer ✓

    hi @bob.lee I looked into the starter code and used another example for the post syntax. The post header is different from the get header and that made it work. for future reference this is the code (you also forgot a {} in the dict:

    requestData = {
    "universe": {
    "symbols": ['SPY.N', 'FCNTX']
    },
    "properties": [{
    "name": "prices",
    # "filter": "MID",
    "period": {
    "startDate": "2023-08-13",
    "endDate": "2023-08-15"
    }
    }]
    }
    accessToken = rdpToken.getToken()
    # POST
    hdrs = {
    'Authorization': "Bearer " + accessToken,
    'Content-Type': "application/json",
    'cache-control': "no-cache"
    }

    dResp = requests.post(RESOURCE_ENDPOINT, headers=hdrs, data = json.dumps(requestData))


    thanks!

Answers

  • @kdayri , I guess you meant to ask what is the format for requesting data using POST method rather than the GET method. If so, the JSON object for the POST request may use slightly different terms from the GET for start and end dates. You can try the sample data below to see if that works.


    {
        "universe": {
            "symbols": ['SPY.N', 'FCNTX']
        },
        "properties": [
            "name": "Prices",
            "filter": "NAV",
            "period": {
                "startDate": "2018-02-01",
                "endDate": "2018-05-05"
            }
        ]
    }
  • thanks @bob.lee .

    I am using `requests.get not `post`. the start code uses it as well and that works. Where can I find a guide on how to structure the call? the request data you suggested did not work unfortunately with this error:


    "code": "400",
    "status": "BadRequest",
    "message": "No Adapter Found",
    "errors": [
    {

    "key": "name",
    "reason": "Invalid Property"
    }