Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Aptos Python SDK

Discord PyPI Package Version PyPI Package Downloads

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

E2E testing and Using the Aptos CLI

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

[!NOTE] The Python SDK does not require the Indexer, if you would prefer to test without it, unset or do not set the environmental variable APTOS_INDEXER_URL and exclude --with-indexer-api from running the aptos node software.

Autoformatting

make fmt

Autolinting

make lint

Package Publishing

  • Download the Aptos CLI.
  • Set the environment variable APTOS_CLI_PATH to the full path of the CLI.
  • uv run python -m aptos_sdk.cli and set the appropriate command-line parameters

Semantic versioning

This project follows semver as closely as possible

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aptos_sdk_fork-0.12.0a4.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aptos_sdk_fork-0.12.0a4-py3-none-any.whl (100.6 kB view details)

Uploaded Python 3

File details

Details for the file aptos_sdk_fork-0.12.0a4.tar.gz.

File metadata

  • Download URL: aptos_sdk_fork-0.12.0a4.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for aptos_sdk_fork-0.12.0a4.tar.gz
Algorithm Hash digest
SHA256 abb10f213713b58008490535b8238fe6ddedfbf4289676fb72c106261f2465a2
MD5 ebff8d85f216ded1e3f6c65701e7d3cf
BLAKE2b-256 516c9b93c98be8c2e086c471b2334e2dffe87c46578a0ce322dbbdada336e7d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptos_sdk_fork-0.12.0a4.tar.gz:

Publisher: publish.yaml on Yolley/aptos-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aptos_sdk_fork-0.12.0a4-py3-none-any.whl.

File metadata

File hashes

Hashes for aptos_sdk_fork-0.12.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 6b40f3973a20440d4d49e506d4542ba375e43eab1c63b058e6f5b8f093a32069
MD5 daba0001c9363cd8377d87530b083ed7
BLAKE2b-256 3759e19f7472a78b5678d33ec504156523af8da2d3823669dab58b3b1e9dd5e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for aptos_sdk_fork-0.12.0a4-py3-none-any.whl:

Publisher: publish.yaml on Yolley/aptos-python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page