Aptos Python SDK
The official Python SDK for interacting with the Aptos blockchain. Get started with the integration guide.
Note: The sync client is deprecated. Please use the async client for all new projects.
Installation
pip install aptos-sdk
Quickstart
import asyncio
from aptos_sdk.account import Account
from aptos_sdk.async_client import FaucetClient, RestClient
async def main():
rest_client = RestClient("https://fullnode.devnet.aptoslabs.com/v1")
faucet_client = FaucetClient("https://faucet.devnet.aptoslabs.com", rest_client)
# Create and fund two accounts
alice = Account.generate()
bob = Account.generate()
await faucet_client.fund_account(alice.address(), 100_000_000)
await faucet_client.fund_account(bob.address(), 0)
# Transfer 1_000 octas from Alice to Bob
txn_hash = await rest_client.bcs_transfer(alice, bob.address(), 1_000)
await rest_client.wait_for_transaction(txn_hash)
print(f"Bob's balance: {await rest_client.account_balance(bob.address())}")
await rest_client.close()
asyncio.run(main())
API Overview
| Class | Description |
|---|---|
RestClient |
Async client for the Aptos REST API (accounts, transactions, events, blocks). |
FaucetClient |
Funds accounts on devnet/testnet via the faucet service. |
Account |
Represents a keypair and address; supports Ed25519 and Secp256k1. |
AccountAddress |
32-byte account address with AIP-40 compliant formatting. |
EntryFunction |
Constructs Move entry function payloads for submission. |
PackagePublisher |
Publishes and upgrades Move packages, with large-package chunking support. |
Development
Requirements
This SDK uses uv for packaging and dependency management:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --extra dev
Unit testing
make test
Quick devnet smoke test
A single command that verifies node, faucet, transaction submission, simulation, balance reads, and indexer (gracefully skipped on rate-limit) all work end-to-end:
make smoke # uses public devnet by default
APTOS_NODE_URL=http://127.0.0.1:8080/v1 \
APTOS_FAUCET_URL=http://127.0.0.1:8081 \
make smoke # against a local testnet
Test coverage
make test-coverage
The legacy aptos_sdk/ package targets ≥ 90 % unit-test coverage. The standalone
v2 package under v2/ targets ≥ 95 %. Coverage from both is uploaded to
Codecov under the v1-sdk and v2-sdk flags respectively.
E2E testing and Using the Aptos CLI
- Download and install the Aptos CLI.
- Set the environment variable
APTOS_CLI_PATHto the full path of the CLI. - Retrieve the Aptos Core Github Repo (git clone https://github.com/aptos-labs/aptos-core)
- Set the environment variable
APTOS_CORE_REPOto the full path of the Repository. make integration_test
You can do this a bit more manually by:
First, run a local testnet (run this from the root of aptos-core):
aptos node run-local-testnet --force-restart --assume-yes --with-indexer-api
Next, tell the end-to-end tests to talk to this locally running testnet:
export APTOS_CORE_REPO="/path/to/repo"
export APTOS_FAUCET_URL="http://127.0.0.1:8081"
export APTOS_INDEXER_URL="http://127.0.0.1:8090/v1/graphql"
export APTOS_NODE_URL="http://127.0.0.1:8080/v1"
Finally run the tests:
make examples
Integration Testing Using the Aptos CLI:
make integration_test
Autoformatting
make fmt
Autolinting
make lint
Package Publishing
- Download the Aptos CLI.
- Set the environment variable
APTOS_CLI_PATHto the full path of the CLI. uv run python -m aptos_sdk.cliand set the appropriate command-line parameters
Semantic versioning
This project follows semver as closely as possible
Metadata
Release files for aptos-sdk 0.12.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aptos_sdk-0.12.2.tar.gz | 485.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aptos_sdk-0.12.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 600.9 kB
Release files / aptos_sdk-0.12.2.tar.gz
| Download URL | aptos_sdk-0.12.2.tar.gz |
|---|---|
| Size | 485.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0edbdd6509a0f1dfe8709ca48b26cfcda74871264005e5a3fdee6ccde8f2bb03
|
|
BLAKE2b-256 checksum How to use checksums |
d8afe0a098114e69c2a90551498fc526b03e758e843da6d19a7662f5c1f10ca5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / aptos_sdk-0.12.2-py3-none-any.whl
| Download URL | aptos_sdk-0.12.2-py3-none-any.whl |
|---|---|
| Size | 115.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a9d790def7cfc1151f212a90beb05f24c7c1fa601eec10eb1f960d1e5fcfe3b
|
|
BLAKE2b-256 checksum How to use checksums |
0b16eb521d33abf98166e27602f5f2bffd8fbbf20cff7b0c72f3bf5cdac2ceda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency log