Darwinium's Python SDKs let your own code call Darwinium APIs. They connect to your nodes over mutual TLS (mTLS) with an API certificate, like the other Darwinium APIs.
| Package | Use it to | Certificate permission | Guide |
|---|---|---|---|
dwn_label_management |
Add, remove and list labels | Edit Labels | Python Label Management SDK |
dwn_erasure |
Erase a person's data when they exercise their right to erasure (GDPR Article 17) | Right to erasure, on every node | Python Erasure SDK |
For the dwn_ext_decision and dwn_ext_call_api packages, see Import Python Packages.
Before you start
You need:
- Python 3.10, 3.11 or 3.12.
- An API certificate. Follow Setting up certificates & Access to create one. Keep the private key, the signed certificate and the CA chain file.
- The certificate's permissions. In the Darwinium Portal, an administrator opens Admin → API Access, double-clicks the certificate, and ticks API Access and the SDK's permission (see the table above) for each node it will call.
- The name of the node to call. Your portal administrator can give you this.
Getting an SDK access token
You need an SDK access token to download the packages.
-
In the Darwinium Portal, click Preferences in the top right corner of the page.

-
Click SDK Access, then Generate Token.

-
Note down the username and token. The username is your Darwinium Portal email. The token is shown only once.
Treat the token like a password: keep it out of source code and notebooks.
Installing a package
Set DARWINIUM_PYPI_USERNAME to your Darwinium Portal email and DARWINIUM_PYPI_PASSWORD to your token. Then install the package with pip:
pip install --extra-index-url=https://${DARWINIUM_PYPI_USERNAME}:${DARWINIUM_PYPI_PASSWORD}@packages.darwinium.com/artifactory/api/pypi/pypi-local/simple "dwn_label_management>=1.5.24"
To install the erasure SDK, use "dwn_erasure>=1.5.24" instead. The --extra-index-url option keeps the public PyPI index available for each package's dependencies.
Package versions follow the Darwinium release cycle.
Creating a client
Every SDK takes the same connection settings:
| Setting | Description |
|---|---|
node_name |
The node's hostname. Your portal administrator can give you this. |
api_endpoint_port |
The node's API port. Defaults to 9443. |
mtls_CA_file_path |
Path to the CA chain file you downloaded with the certificate. |
mtls_cert_file_path |
Path to the signed certificate file. |
mtls_key_file_path |
Path to your private key file. |
mtls_key_file_password |
The private key's password, if it has one. |
For example, with the label SDK:
from dwn_label_management import LabelClient, LabelClientConfig
config = LabelClientConfig(
node_name="<your node name>",
api_endpoint_port=9443,
mtls_CA_file_path="/path/to/cachain.pem",
mtls_cert_file_path="/path/to/cert.pem",
mtls_key_file_path="/path/to/privkey.key",
mtls_key_file_password="<private key password>", # Only if your key has a password
)
client = LabelClient(config)
The erasure SDK's ErasureClientConfig and ErasureClient take the same settings.
Calling the SDK
The SDK methods are asynchronous, so call them with await. In a script, run them inside asyncio.run:
import asyncio
async def main() -> None:
client = LabelClient(config)
page = await client.get_labels(page=0, page_size=20)
print(f"{page.total_count} labels")
asyncio.run(main())
In a Jupyter notebook you can await the calls directly in a cell.