Aptos SDK
Actively maintained. Last release 7 weeks ago, commits in 11 of the last 26 weeks. A safe choice.
pip install aptos-sdkAptos 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. |