Skip to main content

Python Client

py-nillion-client is a Python client for building on top of the Nillion Network. It can be used to manage Nada programs, store and retrieve secrets, and run computations.

Installation

Install the py-nillion-client PyPi package in an existing Python application

pip install py-nillion-client

Usage

Import Python Client

import py_nillion_client as nillion

Initialize a client

Initialize an instance of the NillionClient connected to the Nillion Network using helpers from nillion-python-starter

import os
from dotenv import load_dotenv # pip install python-dotenv
from helpers.nillion_client_helper import create_nillion_client
from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile

# Loads environment variables from the .env file
load_dotenv()

def main():
userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1"))
nodekey = getNodeKeyFromFile(os.getenv("NILLION_NODEKEY_PATH_PARTY_1"))
# Initialize Nillion Client instance
client = create_nillion_client(userkey, nodekey)
# Print the user id
print(client.user_id)

if __name__ == "__main__":
main()

Resources