Tierion makes it easy to create applications that record any data or business process in the blockchain. Tierion’s Hash API lets you anchor data to the blockchain while keeping your data private. Use of the Hash API is free up to 3 records per second or 1,000 records per hour.
In this guide we will be using Python 2.7
1import requests
2import hashlib
Tierion's Hash API uses a JSON Web Token as an access token for authentication. Every request must include a valid access token.
1apiStem = 'https://hashapi.tierion.com/v1'
2
3login_creds = {
4 'username': '[email protected]',
5 'password': 'yourpassword',
6}
7
8reqToken = requests.post(apiPath + '/auth/token', json=login_creds)
9reqToken.json()
10
11token = reqToken.json()['access_token']
12auth1 = {'Authorization': 'Bearer ' + token}
The variable auth1 now contains your access token which is active for one hour.
Now we would like to send a string to get encrypted using SHA-256
1hashText = hashlib.sha256("Matthew Sedaghatfar Using the BlockChain").hexdigest()
2hashItem = '/hashitems'
3myHash = {'hash': hashText}
Then we send this hash to Tierion and get back a receiptId and timestamp.
1respHash = requests.post(apiStem + hashItem, json= myHash, headers = auth1)
2receipt = respHash.json()['receiptId']
3
4respHash.json()
1getReceipts = '/receipts/'
2
3getRec = requests.get(apiStem + getReceipts + receipt,headers = auth1)
4getRe.json()
Some use cases of a Hash API is to store predictions or keeping records of Lease aggrements.