Python code Industry Classification TRKD
Hi Community,
Does anyone have a sample python script to select INDUSTRY CLASSIFICATION from TRKD?
Best,
Andrew
Tagged:
0
Best Answer
-
From theGet Industry Classification Schema Full Hierarchy call on TRKD catalog at LINK.
Here is the sample code:
import requests
import json
import sys
appid = raw_input('Please input appid: ')
token = raw_input('Please input token: ')
requestMsg1 = \
{
"GetIndustryClassificationSchemaFullHierarchy_Request_1":
{
"TaxonomyCode": "RBSS2004",
"LanguageCode": "en-US"
}
}
requestURL = 'http://api.trkd.thomsonreuters.com/api/Fundamentals/Fundamentals.svc/REST/Fundamentals_1/GetIndustryClassificationSchemaFullHierarchy_1'
headers = {'content-type': 'application/json;charset=utf-8', 'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token': token}
result = requests.post(requestURL, data = json.dumps(requestMsg1), headers=headers)
resultText = result.text
print resultText.encode(sys.stdout.encoding, errors='replace')You can inspect the JSON sample request on the TRKD catalog and change the code accordingly.
Red circle is URL endpoint which your request will be sent to.
Pink circle is a token generated from TRKD Create Service Token call.
Blue circle is an application ID assigned to your login.
Green circle is an input.
Here is the sample code to generate a token:
import requests
import json
import getpass
##get username, password and applicationid
username = raw_input('Please input username: ')
##use getpass.getpass to hide user inputted password
password = getpass.getpass(prompt='Please input password: ')
appid = raw_input('Please input appid: ')
##create authentication request URL, message and header
#{
# "CreateServiceToken_Request_1":{
# "ApplicationID": <application id>,
# "Username": <username>,
# "Password": <password>
# }
#}
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'}
#send request
result = requests.post(authenURL, data = json.dumps(authenMsg), headers=headers)
if result.status_code == 200:
print 'Request success'
print 'response status %s'%(result.status_code)
##get Token
token = result.json()['CreateServiceToken_Response_1']['Token']
print 'Token: %s'%(token)
##get expiration
expire = result.json()['CreateServiceToken_Response_1']['Expiration']
print 'Expire: %s'%(expire)
elif result.status_code == 500:
print 'Request fail'
print 'response status %s'%(result.status_code)
print 'Error: %s'%(result.json())
print result.text
#{
# "CreateServiceToken_Response_1": {
# "Expiration": "2016-09-26T09:42:54.4335265Z",
# "Token": "xxxxxxxxxx..."
# }
#}0
Answers
-
Hi,
Thanks very much for this, much appreciated!
Andrew
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛