Using of CREDITS API in Python 3 (demo)
Requirements
Windows x64
Download CREDITS API files: https://github.com/CREDITSCOM/thrift-interface-definitions
Development Environment: https://www.jetbrains.com/pycharm/
Additional libraries:
base58
thrift
Create Application
You have to add them via the PyCharm IDE package manager, for example:
Create console applications (Python 3) in PyCharm IDE
CREDITS API Source Code Generation
Open the folder which you have used for download of Credits API from the GitHub, for example, in d: \ credits \ github \ CS-API \
Let's say thrift is installed to the folder: d: \ vcpkg \
execute commands:
D: \ vcpkg \ packages \ thrift_x64-windows \ tools \ thrift \ thrift.exe --gen py api.thrift
D: \ vcpkg \ packages \ thrift_x64-windows \ tools \ thrift \ thrift.exe --gen py variant.thrift
As the result will be a folder with files: gen-cpp, copy the files from the folder to the folder of our application, for example in: d: \ credits \ app \ app \
Add files to our project

Add the code
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
from thrift.transport.TSocket import TSocket
import base58
from gen.api.API import Client
publicKey = 'H5ptdUUfjJBGiK2X3gN2EzNYxituCUUnXv2tiMdQKP3b'
publicKeyBytes = base58.b58decode(publicKey)
try:
tr = TSocket('127.0.0.1', 9090)
protocol = TBinaryProtocol(tr)
client = Client(protocol)
tr.open()
balance = client.BalanceGet(publicKeyBytes, 0)
print(balance)
transactionGetResult = client.TransactionsGet(publicKeyBytes, 0, 5)
print(transactionGetResult)
except:
print("Oops. Unexpected error.")
Check the performance. Call the GetBalance Method.
As the result of the program we see the requested balance:

GitHub link: https://github.com/pvl1175/CreditsPythonApiDemo