A set of core Algorand utilities written in Python and released via PyPi that make it easier to build solutions on Algorand. This project is part of AlgoKit.
The goal of this library is to provide intuitive, productive utility functions that make it easier, quicker and safer to build applications on Algorand. Largely these functions wrap the underlying Algorand SDK, but provide a higher level interface with sensible defaults and capabilities for common tasks.
Note If you prefer TypeScript there's an equivalent TypeScript utility library.
This library can be installed using pip, e.g.:
pip install algokit-utils
This repository includes Pydantic validation schemas for development-time validation of API client responses. These are test fixtures, not shipped as part of the published package.
from tests.fixtures.schemas.algod import AccountSchema, NodeStatusResponseSchema
# Validate API responses
response = algod_client.status()
validated = NodeStatusResponseSchema.model_validate(response)
print(f"Last round: {validated.last_round}")Features:
- Type validation (str, int, bool, etc.)
- Uint64 bounds checking (0 to 2^64-1)
- Nested schema support
- 208 schemas across algod, kmd, and indexer clients
For developers - regenerate schemas:
poe generate-schemasSee VALIDATION.md for details.
Refer to the v3 migration guide for more information on how to migrate to latest version of algokit-utils-py.
This library follows the Guiding Principles of AlgoKit.
This is an open source project managed by the Algorand Foundation. See the AlgoKit contributing page to learn about making improvements.
To successfully run the tests in this repository you need to be running LocalNet via AlgoKit:
algokit localnet start
Tests under tests/modules/ use a mock server for deterministic API testing against pre-recorded HAR files. The mock server is managed externally (not by pytest).
In CI: Mock servers are automatically started via the algokit-polytest GitHub Action.
Local development:
- Clone algokit-polytest and start the mock servers:
# Clone algokit-polytest (if not already)
git clone https://github.com/algorandfoundation/algokit-polytest.git
# Start all mock servers (recommended)
cd algokit-polytest/resources/mock-server
./scripts/start_all_servers.shThis starts algod (port 8000), kmd (port 8001), and indexer (port 8002) in the background.
- Set environment variables and run tests:
export MOCK_ALGOD_URL=http://localhost:8000
export MOCK_INDEXER_URL=http://localhost:8002
export MOCK_KMD_URL=http://localhost:8001
# Run all module tests
pytest tests/modules/
# Or run specific client tests
pytest tests/modules/algod_client/- Stop servers when done:
cd algokit-polytest/resources/mock-server
./scripts/stop_all_servers.sh| Environment Variable | Description | Default Port |
|---|---|---|
MOCK_ALGOD_URL |
Algod mock server URL | 8000 |
MOCK_INDEXER_URL |
Indexer mock server URL | 8002 |
MOCK_KMD_URL |
KMD mock server URL | 8001 |
Environment variables can also be set via .env file in project root (copy from .env.template).