question

Upvotes
Accepted
3 0 0 2

Download Filings through RDP with RWS license?

Hi all,

I am asking this question even though I think I already know the answer, but I just want to look for confirmation and similar experiences from your side.


I am interested in downloading Global Filings documents that I already found in Workspace. I can download them manually there, e.g. BASFn.DE -> go to Filings tab and then download e.g. the pdf of "BASF Report 2022 (BASF Group)" (document title) dated 24-Feb-2023 (fill date).


I don't want to download the documents manually in Workspace, but use an API solution.


I found this nice introductory article Introduction To Filings - Python | Devportal (refinitiv.com) and tried to run the code there. I have reproduced the code in the attached file in a slightly more compressed form:

# import packages
import requests, json, time, os

# set credentials
USERNAME  = ""
PASSWORD  = ""
CLIENT_ID = ""

# Set Application Constants
RDP_AUTH_VERSION = "/v1"
RDP_FILINGS_VERSION = "/beta1"
RDP_BASE_URL = "https://api.refinitiv.com"
CATEGORY_URL = "/auth/oauth2"
ENDPOINT_URL = "/token"
CLIENT_SECRET = ""
TOKEN_FILE = "token.txt"
SCOPE = "trapi"


# generate access and refresh token
TOKEN_ENDPOINT = RDP_BASE_URL + CATEGORY_URL + RDP_AUTH_VERSION + ENDPOINT_URL

def _requestNewToken(refreshToken):
    if refreshToken is None:
        tData = {
            "username": USERNAME,
            "password": PASSWORD,
            "grant_type": "password",
            "scope": SCOPE,
            "takeExclusiveSignOnControl": "true"
        };
    else:
        tData = {
            "refresh_token": refreshToken,
            "grant_type": "refresh_token",
        };

    ## Make a REST call to get latest access token
    response = requests.post(
        TOKEN_ENDPOINT,
        headers = {
            "Accept": "application/json"
        },
        data = tData,
        auth = (
            CLIENT_ID,
            CLIENT_SECRET
        )
    )
    
    if response.status_code != 200:
        raise Exception("Failed to get access token {0} - {1}".format(response.status_code, response.text));

    ## Return the new token
    return json.loads(response.text);

def saveToken(tknObject):
    tf = open(TOKEN_FILE, "w+");
    print("Saving the new token");
    ## Append the expiry time to token
    tknObject["expiry_tm"] = time.time() + int(tknObject["expires_in"]) - 10;
    ## Store it in the file
    json.dump(tknObject, tf, indent=4)
    
def getToken():
    try:
        print("Reading the token from: " + TOKEN_FILE);
        ## Read the token from a file
        tf = open(TOKEN_FILE, "r+")
        tknObject = json.load(tf);

        ## Is access token valid
        if tknObject["expiry_tm"] > time.time():
            # return access token
            #print(tknObject["expiry_tm"])
            #print("time.time()="+ str(time.time()))
            return tknObject["access_token"];

        print("Token expired, refreshing a new one...");
        tf.close();
        ## Get a new token from refresh token
        tknObject = _requestNewToken(tknObject["refresh_token"]);

    except Exception as exp:
        print("Caught exception: " + str(exp))
        print("Getting a new token using Password Grant...");
        tknObject = _requestNewToken(None);

    ## Persist this token for future queries
    saveToken(tknObject)
    ## Return access token
    return tknObject["access_token"]

accessToken = getToken()
print("Have token now")
#print("Token is: " + accessToken)

# document retrieval

## some document
retrievalParameters = "docId/54932207"

## endpoint
ENDPOINT_DOC_RETRIEVAL = RDP_BASE_URL + '/data/filings' + RDP_FILINGS_VERSION + '/retrieval/search/' + retrievalParameters

## headers
headers = {
    "Authorization": "Bearer " + accessToken,
    "X-API-Key": "155d9dbf-f0ac-46d9-8b77-f7f6dcd238f8",
    "ClientID" : "api_playground"
}

# request
print("Next we retrieve: " + ENDPOINT_DOC_RETRIEVAL);

response = requests.get(ENDPOINT_DOC_RETRIEVAL, headers = headers);

print("Response status code = "+str(response.status_code))
print("Response text = ", json.dumps(json.loads(response.text), indent=4))


I get the following error message:

Response text = {

"error": {

"code": "insufficient_scope",

"message": "access denied. Scopes required to access the resource: [trapi.data.filings.retrieval]. Missing scopes: [trapi.data.filings.retrieval]",

"status": "Forbidden"

}

This scope [trapi.data.filings.retrieval] is also not listed here https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis/tutorials#authorization-all-about-tokens, So I assume that the Filings API is an additional service that you have to subscribe to and is not included in a Workspace license.

I also found in the README of another example code https://github.com/Refinitiv-API-Samples/Article.RD.Python.PredictiveModellingForFilings that I need


To summarize:

  • Filings cannot be downloaded via an API solution with an RWS (Refinitiv Workspace for Students) license. Right?
  • Can you also explain to me what this is (the header arguments of ENDPOINT_DOC_RETRIEVAL in the document retrieval endpoint; see code):
    • "X-API-Key": "155d9dbf-f0ac-46d9-8b77-f7f6dcd238f8",
    • "ClientID" : "api_playground"


Many thanks

Philip


#technologyrdp-apierror-403download-fileapi-documentation
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

<AHS>

user opened the ticket number 12630908 and got redirected to this forum. I'm going to talk to the ticket owner as this is related to entitlement, not API usage issue

Upvotes
Accepted
14.1k 30 5 10

Hi @schwedler ,

I'm sorry to hear that you're having this issue. I found the ticket you created for the support team on the same issue then I'm reaching out to the support team to check the entitlement on your account and the further action because this is not an issue with your code to call the API as you can get the response from the API properly. We will keep you updated.

Hope this helps and please let me know in case you have any further questions.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 0 0 2

Hi @raksina.samasiri

Thank you for contacting me. The support team has forwarded me to the developer community. I hope you will be able to find out more.

I am looking forward to your response.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 0 0 2

Hi @raksina.samasiri

Thanks for pushing this request to my account manager. Indeed this request needs additional licensing. With a Workspace license you can only use the Bulk Download option via the Batch Print/Save App (needs an additional installation) to download multiple reports at the same time.

All the best!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.