Skip to main content

Getting Started With Python

Password Storage

Never store passwords or seeds on a host's environment variables or in the source code in a production setup. Please follow our backup and security recommendations for production use.

Requirements

Install package from PyPI

You can install the library by executing pip install iota-client.

Install from source

caution

We recommend to install the library with pip from PyPI. Only compile the library from source if you are in need of some unreleased features or are working with an unsupported computer architecture.

Additional Requirements

  • Rust and Cargo.
  • (for Linux only) libudev. You can install it with apt install libudev-dev.

Clone the Repository

You can clone the iota.rs client library by running the following command:

git clone -b develop https://github.com/iotaledger/iota.rs

Change to the Python Binding Directory

After you have cloned the repository, you should change directory to iota.rs/client/bindings/python. You can do so by running the following command:

cd iota.rs/client/bindings/python

Install the Required Dependencies and Build the Wheel

Once you have cloned the repository, and moved to the binding's directory, you should install dependencies and build the wheel file.

You can do so by running the following commands:

pip install -r requirements-dev.txt
pip install .

(optional) Create and Use a Virtual Environment

If you want to isolate the library from the rest of your system, you can create a virtual environment by running the following commands:

Linux/MacOs

python3 -m venv iota_client_venv
source iota_client_venv/bin/activate

Windows

.\iota_client_venv\Scripts\activate

(optional) Deactivate the virtual environment

If you want to deactivate the virtual environment, you should run the following command from the virtual environment:

deactivate

Use the Library

After you installed the library, you can create a IotaClient instance and interface with it.

from iota_client import IotaClient

# Create an IotaClient instance
client = IotaClient({'nodes': ['https://api.testnet.shimmer.network']})

# Get the node info
node_info = client.get_info()
print(f'{node_info}')

What's Next?

Now that you are up and running, you can get acquainted with the library using its how-to guides and the repository's code examples.