Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TRKD /
avatar image
Question by tarun_dutta · Jun 25, 2020 at 02:26 PM · pythonpython apitrkdrkd

get data using API in python

I want to retrieve the data using python


This is the following code. Please tell me where am I doing wrong.


##create authentication request URL, message and header

authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}

authenURL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1'

headers = {'content-type': 'application/json;charset=utf-8'}

result = requests.post(authenURL, data = json.dumps(authenMsg), headers=headers)

try:

if result.status_code == 200:

print('response status %s'%(result.status_code))

token = result.json()['CreateServiceToken_Response_1']['Token']

print('Token: %s'%(token))

expire = result.json()['CreateServiceToken_Response_1']['Expiration']


else:

print('response status %s'%(result.status_code))

if result.status_code == 500: ## if username or password or appid is wrong

print('Error: %s'%(result.json()))

result.raise_for_status()

except requests.exceptions.RequestException as e:

print('Exception!!!')

print(e)

sys.exit(1)


headers_ = {

"POST": "/api/Fundamentals/Fundamentals.svc HTTP/1.1"

,"Content-Type": "application/soap+xml"

,"Host": "api.trkd.thomsonreuters.com"

,"Content-Length": "1"

,'X-Trkd-Auth-Token': token

}

url = "http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc";

r = requests.post(url, data = json.dumps(authenMsg), headers=headers_)

print(r)




People who like this

0 Show 1
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Gurpreet ♦♦ · Jun 25, 2020 at 02:49 PM 0
Share

Moving to TRKD forum

4 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by wasin.waeosri · Jun 26, 2020 at 10:01 AM

Hello @tarun_dutta

I have checked your error message and the code. The problems are following:

  1. The application sends the HTTP Post request message to RKD Fundamental Service SOAP endpoint. You cannot send the HTTP Post request message to the SOAP API endpoint
  2. The application sends the authentication request message as a Fundamental request message to RKD Fundamental service.

I strongly suggest you check the RKD Fundamental Service information in RKD API Catalog page, then choose Fundamentals --> Get General Information. The service supports both SOAP and HTTP JSON interfaces. You can find the url endpoint, request message detail and example result from the page.

Based on RKD API page above, the URL for Fundamentals service : General Company Information HTTP JSON interface is

http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc/REST/Fundamentals_1/GetGeneralInformation_1

The example request message in JSON format is following:

{
    "GetGeneralInformation_Request_1": {
        "companyId": "IBM.N",
        "companyIdType": "RIC",
        "ShowReferenceInformation": False
    }
}

I have tested the following example code, and it works fine in my environment.

fundamental_header= {
    'content-type': 'application/json',
     'X-Trkd-Auth-ApplicationID': appid, 
     'X-Trkd-Auth-Token': token
}
fundamental_request_message = {
    "GetGeneralInformation_Request_1": {
        "companyId": "IBM.N",
        "companyIdType": "RIC",
        "ShowReferenceInformation": False
    }
}
url = "http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc/REST/Fundamentals_1/GetGeneralInformation_1"
result = requests.post(url, data = json.dumps(fundamental_request_message), headers=fundamental_header)
print(result.json())

fundamental.png (168.5 KiB)
fundamental-2.png (165.7 KiB)
Comment
tarun_dutta

People who like this

1 Show 2 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
wasin.waeosri ♦♦ · Jul 03, 2020 at 07:18 AM 0
Share

Hi @tarun_dutta

Please be informed that the RKD API endpoints have been changed from "api.trkd.thomsonreuters.com" to "api.rkd.refinitiv.com". you can find more detail in this https://my.refinitiv.com/content/mytr/en/pcnpage/11735.html link.

avatar image
tarun_dutta · Jul 03, 2020 at 08:18 AM 0
Share

Thanks It worked How do I get the company id for some companies at one shot using api query

avatar image
REFINITIV
Answer by Gurpreet · Jun 25, 2020 at 02:53 PM

Hi @tarun_dutta,

Your code seems to be ok. What is the issue?

Have you seen TRKD samples at Refinitiv API github?

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by Gurpreet · Jun 25, 2020 at 03:04 PM

I ran your code and was able to get a token:

response status 200
Token: E3E7AE98E64D8DE3B4E5720******C4137D
<Response [400]>
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
REFINITIV
Answer by wasin.waeosri · Jun 26, 2020 at 03:48 AM

Hello @tarun_dutta

Could you please give me more detail regarding the error you got, example error message?

Please note that the given code is just the code for authenticating for TRKD service token, the application needs to use this service token (and the application id) when request data from the other TRKD services (Quote, Estimate, Time-Series, News, Research, etc).


The application needs to set the Application ID and service Token with the request message HTTP header to identify the permission.

  • X-Trkd-Auth-ApplicationID: Application ID
  • X-Trkd-Auth-Token: service Token

For more detail, please see an example of how to request TRKD data after you get a service token from the following resources:

  • How to implement TRKD JSON application with Python chapter 1: the basic
  • How to implement TRKD JSON application with Python chapter 2: Quote
  • TRKD Tutorial
Comment
SupDev1

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
tarun_dutta · Jun 26, 2020 at 08:40 AM 0
Share

Hi
The error is 400.


I have passed the appid, and token in data.



headers_ = {

"POST": "/api/Fundamentals/Fundamentals.svc HTTP/1.1"

,"Content-Type": "application/soap+xml"

,"Host": "api.trkd.thomsonreuters.com"

,"Content-Length": "1"

}


reqmsg = {'X-Trkd-Auth-ApplicationID': appid

,'X-Trkd-Auth-Token': token}

url = "http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc";

r = requests.post(url, data = json.dumps(reqmsg), headers=headers_)

print(r)


However, I am getting


response status 200 
Token: 029F398BA861B10AC4DC90F6B2FBD55C6FADE5DB3FAC5DFBCEF5B21C2DD3A93E128DAA983DC1AF43377D94D5F6CDA6198729263B51DC33C08423465C2967BB78983654FF282F33FEC5C8764C6023C944191750086E98181DBB9C19F351D 
<Response [400]>

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

Python code Industry Classification TRKD

Is there a Python Sample code available for Filings Search and Filings Retrieval service in RKD API?

Swagger for TRKD Json api

What are the possible responses for Prod_Perm and the meaning for each?

Quote's api slow to respond

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges