Skip to content

Commit c09077b

Browse files
author
Wasin Waeosri
committed
authen and basic quote work fine
1 parent ff8afb4 commit c09077b

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

result.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
response status 200
2+
response header {'Content-Length': '282', 'X-AspNet-Version': '4.0.30319', 'X-Powered-By': 'ASP.NET', 'Server': 'Microsoft-IIS/8.0', 'X-TRKD-ServerName': 'CZP/API4', 'Cache-Control': 'no-store', 'Date': 'Thu, 25 Aug 2016 09:43:51 GMT', 'Content-Type': 'application/json'}
3+
response raw data = {u'CreateServiceToken_Response_1': {u'Token': u'304A3910DC2A318B4855197B183350AC33382A758EB825C74E66DBEF4C8F4426C1769DB066B337882202EFE6D4540CBB2C027FA7EA184EFCEDE9831F6F332E91A7B19908391EA04EE65B8166BDE83A49FA3E6AEF29E51E1C83B6CCF6482E743F', u'Expiration': u'2016-08-25T11:13:52.0951116Z'}}

testpy.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
import zeep
1+
import requests
2+
import json
23

34
username = 'trcsmnldauki@thomsonreuters.com'
45
appid = 'rkdapi'
56
password = 'Welcome75'
67

7-
authen_wsdl = 'http://api.rkd.reuters.com/schemas/wsdl/TokenManagement_1_HttpsAndAnonymous.wsdl'
8-
quote_wsdl = 'http://api.rkd.reuters.com/schemas/wsdl/Quotes_1_HttpAndRKDToken.wsdl'
9-
client = zeep.Client(wsdl=authen_wsdl)
8+
authenURL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1'
9+
10+
authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}
11+
headers = {'content-type': 'application/json;charset=utf-8'}
12+
13+
result = requests.post(authenURL, data = json.dumps(authenMsg), headers=headers)
14+
print 'response status %s'%(result.status_code)
15+
print 'response header %s'%(result.headers)
16+
print 'response raw data = %s'%(result.json())
17+
18+
token = result.json()['CreateServiceToken_Response_1']['Token']
19+
print token
20+
expire = result.json()['CreateServiceToken_Response_1']['Expiration']
1021

11-
authen_request = client.get_type

testquote.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import requests
2+
import json
3+
4+
username = 'trcsmnldauki@thomsonreuters.com'
5+
appid = 'rkdapi'
6+
password = 'Welcome75'
7+
8+
authenURL = 'https://api.trkd.thomsonreuters.com/api/TokenManagement/TokenManagement.svc/REST/Anonymous/TokenManagement_1/CreateServiceToken_1'
9+
10+
authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}
11+
headers = {'content-type': 'application/json'}
12+
13+
result = requests.post(authenURL, data = json.dumps(authenMsg), headers=headers)
14+
print 'response status %s'%(result.status_code)
15+
print 'response header %s'%(result.headers)
16+
print 'response raw data = %s'%(result.json())
17+
18+
token = result.json()['CreateServiceToken_Response_1']['Token']
19+
20+
21+
quoteURL = 'https://api.trkd.thomsonreuters.com/api/Quotes/Quotes.svc/REST/Quotes_1/RetrieveItem_3'
22+
23+
headers = {'content-type': 'application/json;charset=utf-8' ,'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token' : token}
24+
25+
quoteRequestMsg = {
26+
'RetrieveItem_Request_3': {
27+
'TrimResponse': False,
28+
'ItemRequest': [
29+
{
30+
'Fields': 'CF_LAST:CF_HIGH:CF_LOW:CF_BID:CF_ASK:CF_YIELD:CF_DATE:CF_TIME:CF_VOLUME:CF_CLOSE:CF_OPEN:CF_NAME',
31+
'RequestKey': [
32+
{
33+
'Name': 'VOD.L',
34+
'NameType': 'RIC'
35+
}
36+
],
37+
'Scope': 'List',
38+
'ProvideChainLinks': True
39+
}
40+
]
41+
}
42+
}
43+
44+
quoteresult = requests.post(quoteURL, data = json.dumps(quoteRequestMsg), headers=headers)
45+
print quoteresult.json()

0 commit comments

Comments
 (0)