> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Python SDK for Solana

> Learn how to interact with Solana using the Python SDK (michaelhly/solana-py).

## Solana Python SDK

There are two packages that are useful for developing with Python. Install both
from PyPI (the current `solana` release needs Python 3.11 or later):

```bash Terminal
pip install solana solders
```

The cookbook's Python examples are tested with `solana` 0.41. That release has
no synchronous `Client`: send RPC requests with `AsyncClient` from
`solana.rpc.async_api`.

[`solana`](https://github.com/michaelhly/solana-py) (solana-py)

- solana-py is the base Python library for interacting with Solana.
- You can use it to build transactions and interact with the
  [Solana JSON RPC API](/developers/docs/rpc), much like you would do with
  [solana-web3.js](https://github.com/solana-foundation/solana-web3.js).
- It also covers the
  [SPL Token Program](https://www.solana-program.com/docs/token) (`spl.token`).
- [Latest Documentation](https://michaelhly.com/solana-py/).

[`solders`](https://github.com/kevinheavey/solders)

`solders` is a high-performance Python toolkit for Solana, written in Rust. It
covers:

- Core SDK functionality: keypairs, pubkeys, signing, and serializing
  transactions.
- RPC: building requests and parsing responses (for networking and asynchronous
  APIs, [solana-py](https://michaelhly.com/solana-py/rpc/async_api/) is the
  recommended option).
- Integration testing: the `solders.litesvm` module is an alternative to
  `solana-test-validator` that's much more convenient and **much** faster.

## Solana Client Python SDK

If you want to interact with Solana contracts with Python, you can use clients
SDK to render Solana rust contracts to Python clients, if only you can get the
IDL file of the contract.

[`Codama-py`](https://www.npmjs.com/package/codama-py)

- Standardize any Solana onchain contract program to
  [`Codama IDL`](https://github.com/codama-idl/codama) and generate an
  interactive Python client.
- Supports both Anchor and custom programs.
- Still in beta (0.1.7-beta).

[`AnchorPy`](https://github.com/kevinheavey/anchorpy)

- AnchorPy is a Python client for Anchor programs. It can generate clients from
  Anchor IDL files, and interact with Anchor programs.
- Its last release, 0.21.0, is from March 2025. It requires an older solana-py:
  installing it downgrades `solana` to 0.36 and `solders` to 0.26, so keep it in
  a separate virtual environment from code written for `solana` 0.41.

## Solana Python Cookbook

[`Solana Python Cookbook`](/developers/cookbook) A collection of examples and
recipes for developing Solana using Python SDK.
