---
title: "Using Python with Radix"
url: "https://radix.wiki/contents/resources/python-scripts/using-python-with-radix"
updated: 2026-11-03
license: CC-BY-4.0
license_url: "https://creativecommons.org/licenses/by/4.0/"
version: "1.0.0"
---

# Using Python with Radix

| Using Python with Radix |  |
| --- | --- |
| Read and submit | [Gateway API](/contents/tech/core-protocols/radix-gateway-api), JSON over HTTPS |
| Build and sign | [radix-engine-toolkit](https://pypi.org/project/radix-engine-toolkit/) on PyPI, 2.3.5 (25 March 2026), Python 3.6 or later |
| Public Gateways | `https://mainnet.radixdlt.com` (network id 1), `https://stokenet.radixdlt.com` (network id 2) |
| Toolkit source | [radixdlt/radix-engine-toolkit](https://github.com/radixdlt/radix-engine-toolkit), Rust, wrapped for Python with UniFFI |
| Related | [Radix Engine Toolkit](/developers/transactions/04-radix-engine-toolkit) · [Transaction Lifecycle](/developers/transactions/02-transaction-lifecycle) |

## Introduction

A Python program works with Radix through two pieces, and needs no node of its own. The [Gateway API](/contents/tech/core-protocols/radix-gateway-api) is a public JSON service over HTTPS that reads ledger state and accepts finished transactions, so any Python HTTP client can call it ([Network APIs](https://docs.radixdlt.com/docs/network-apis)). The [radix-engine-toolkit](https://pypi.org/project/radix-engine-toolkit/) package on PyPI builds, signs and compiles transactions on the machine running the script; it is generated from the Rust [Radix Engine Toolkit](https://github.com/radixdlt/radix-engine-toolkit) with UniFFI, the same core behind the TypeScript, Swift, C# and Kotlin wrappers.

Reading the ledger needs only the Gateway. Writing to it needs both: the toolkit makes the signed transaction, and the Gateway carries it to the network.

## How do I read Radix ledger data in Python?

Send a POST request with a JSON body to a Gateway endpoint. `/status/gateway-status` returns the current ledger state, including the epoch, and `/state/entity/details` returns the details and metadata of up to 20 addresses per call ([Gateway API schema](https://github.com/radixdlt/babylon-gateway/blob/main/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml)). This reads the current epoch and the total supply of $XRD from the public mainnet Gateway:

```
import requests

GATEWAY = "https://mainnet.radixdlt.com"
XRD = "resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd"

status = requests.post(f"{GATEWAY}/status/gateway-status", json={}).json()
print("epoch", status["ledger_state"]["epoch"])

details = requests.post(f"{GATEWAY}/state/entity/details", json={"addresses": [XRD]}).json()
print("supply", details["items"][0]["details"]["total_supply"])
```

Every endpoint and field is listed in the [Gateway API reference](https://radix-babylon-gateway-api.redoc.ly/). A script that polls heavily or runs in production can point the same code at a commercial Gateway instead; Radix keeps a list of [Gateway providers](https://docs.radixdlt.com/docs/gateway-api-providers). For transaction history, `/stream/transactions` pages through committed transactions with filters by account, resource and event.

## How do I build and submit a Radix transaction in Python?

Install the toolkit with `pip install radix-engine-toolkit` and follow four steps, which the [package page](https://pypi.org/project/radix-engine-toolkit/) shows in full against [Stokenet](/contents/tech/releases/stokenet):

1. **Write the manifest.** `ManifestBuilder` chains instructions, such as locking a fee, taking $XRD from the Stokenet faucet and depositing it to an account, and `.build(network_id)` returns a `TransactionManifest`. A [transaction manifest](/contents/tech/core-protocols/transaction-manifests) is the list of instructions the network runs in order.
2. **Set the header.** `TransactionHeader` takes the network id, a start and end epoch, a random nonce, the notary's public key and a tip. The toolkit has no view of the ledger, so the epoch comes from the Gateway's `/status/gateway-status`.
3. **Sign and notarize.** `TransactionBuilder` joins header and manifest, signs with each signer's private key and notarizes. `statically_validate` raises an exception if the transaction is malformed, and `intent_hash()` gives the transaction's id.
4. **Submit through the Gateway.** The toolkit does not submit anything. `bytearray(transaction.compile()).hex()` is the payload for `/transaction/submit`, sent as `notarized_transaction_hex`; `/transaction/status` then takes the intent hash and reports whether it committed ([Gateway API schema](https://github.com/radixdlt/babylon-gateway/blob/main/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml)).

Private keys stay in the script's process: nothing in this flow sends a key to the Gateway. The toolkit's [developer guide](/developers/transactions/04-radix-engine-toolkit) covers what it can and cannot check before submission, and the [transaction lifecycle](/developers/transactions/02-transaction-lifecycle) covers what happens after.

## Which Python scripts does this wiki keep?

Two analysis scripts sit beside this page: the [DLT Efficiency Metric](/contents/resources/python-scripts/dlt-efficiency-metric), which sets GitHub repository counts against Google Trends interest for five networks, and [Proof of Work](/contents/resources/python-scripts/proof-of-work), a worked mining example. Neither talks to the Radix ledger.

## External Links

- [radix-engine-toolkit on PyPI](https://pypi.org/project/radix-engine-toolkit/)
- [Radix Engine Toolkit on GitHub](https://github.com/radixdlt/radix-engine-toolkit)
- [Gateway API reference](https://radix-babylon-gateway-api.redoc.ly/)
- [Radix Docs: Network APIs](https://docs.radixdlt.com/docs/network-apis)
- [Radix Docs: Gateway API providers](https://docs.radixdlt.com/docs/gateway-api-providers)
