Python client introduction
Python API documentation: https://tinychain.readthedocs.io/

Install the client

The easy way to install TinyChain's Python client is using Pip:
1
# on very new operating systems this command may be "pip" instead of "pip3"
2
pip3 install tinychain
Copied!

Hello, World!

You can verify that you've installed the Python client correctly by running this Hello, World! program:
1
import tinychain as tc
2
3
# This host is available for demonstration purposes, but may be slow
4
# due to the volume of requests it receives.
5
HOST = tc.host.Host("http://demo.tinychain.net")
6
7
# This endpoint will attempt to execute resolve whatever State it receives,
8
# without committing any write operations.
9
ENDPOINT = "/transact/hypothetical"
10
11
@tc.get_op
12
def hello(name: tc.String):
13
return tc.String("Hello, {{name}}!").render(name=name)
14
15
if __name__ == "__main__":
16
cxt = tc.Context()
17
cxt.hello = hello
18
cxt.result = cxt.hello("World")
19
print(HOST.post(ENDPOINT, cxt))
Copied!
If you have any trouble with the host at demo.tinychain.net, you can run your own host by following the steps in Run a TinyChain host.