Solana Python API
Project Links
Meta
Author: Michael Huang
Requires Python: >=3.9,<4.0
Classifiers
Intended Audience
- Developers
License
- OSI Approved :: MIT License
Natural Language
- English
Programming Language
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Solana.py
๐ The Solana Python SDK ๐
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, much like you would do with solana-web3.js
It also covers the SPL Token Program.
Note: This library uses many core types from the Solders package which used to be provided by solana-py itself. If you are upgrading from an old version and you're looking for something that was deleted, it's probably in solders now.
โ๏ธ See also: AnchorPy, a Python client for Anchor-based programs on Solana. โ๏ธ
โก Quickstart
Installation
- Install Python bindings for the solana-sdk.
pip install solders
- Install this package to interact with the Solana JSON RPC API.
pip install solana
General Usage
API Client
from solana.rpc.api import Client
http_client = Client("https://api.devnet.solana.com")
Async API Client
import asyncio
from solana.rpc.async_api import AsyncClient
async def main():
async with AsyncClient("https://api.devnet.solana.com") as client:
res = await client.is_connected()
print(res) # True
# Alternatively, close the client explicitly instead of using a context manager:
client = AsyncClient("https://api.devnet.solana.com")
res = await client.is_connected()
print(res) # True
await client.close()
asyncio.run(main())
Websockets Client
import asyncio
from asyncstdlib import enumerate
from solana.rpc.websocket_api import connect
async def main():
async with connect("wss://api.devnet.solana.com") as websocket:
await websocket.logs_subscribe()
first_resp = await websocket.recv()
subscription_id = first_resp[0].result
next_resp = await websocket.recv()
print(next_resp)
await websocket.logs_unsubscribe(subscription_id)
# Alternatively, use the client as an infinite asynchronous iterator:
async with connect("wss://api.devnet.solana.com") as websocket:
await websocket.logs_subscribe()
first_resp = await websocket.recv()
subscription_id = first_resp[0].result
async for idx, msg in enumerate(websocket):
if idx == 3:
break
print(msg)
await websocket.logs_unsubscribe(subscription_id)
asyncio.run(main())
๐จ Development
Setup
- Install poetry
- Install dev dependencies:
poetry install
- Activate the poetry shell.
poetry shell
Lint
make lint
Tests
# All tests
make tests
# Unit tests only
make unit-tests
# Integration tests only
make int-tests
0.36.12
May 14, 2026
0.36.11
Jan 03, 2026
0.36.10
Nov 18, 2025
0.36.9
Aug 09, 2025
0.36.7
Jun 05, 2025
0.36.6
Feb 22, 2025
0.36.5
Feb 08, 2025
0.36.4
Feb 08, 2025
0.36.3
Jan 25, 2025
0.36.2
Jan 02, 2025
0.36.1
Dec 12, 2024
0.36.0
Dec 11, 2024
0.35.1
Nov 10, 2024
0.35.0
Oct 12, 2024
0.34.3
Jul 31, 2024
0.34.2
Jun 09, 2024
0.34.0
Apr 17, 2024
0.33.0
Mar 29, 2024
0.32.0
Feb 12, 2024
0.31.0
Jan 01, 2024
0.30.2
Jun 02, 2023
0.30.1
May 14, 2023
0.30.0
May 05, 2023
0.29.2
Mar 24, 2023
0.29.1
Feb 02, 2023
0.29.0
Jan 13, 2023
0.28.1
Dec 07, 2022
0.28.0
Oct 31, 2022
0.27.2
Oct 15, 2022
0.27.1
Oct 14, 2022
0.27.0
Oct 14, 2022
0.26.0
Oct 13, 2022
0.25.1
Jul 25, 2022
0.25.0
Jun 22, 2022
0.24.0
Jun 04, 2022
0.23.3
Apr 29, 2022
0.23.2
Apr 18, 2022
0.23.1
Apr 01, 2022
0.23.0
Mar 07, 2022
0.22.0
Mar 04, 2022
0.21.0
Jan 13, 2022
0.20.0
Dec 30, 2021
0.19.1
Dec 22, 2021
0.19.0
Dec 02, 2021
0.18.3
Nov 20, 2021
0.18.2
Oct 31, 2021
0.18.1
Oct 20, 2021
0.18.0
Oct 19, 2021
0.17.0
Oct 11, 2021
0.16.0
Oct 06, 2021
0.15.1
Sep 27, 2021
0.15.0
Sep 26, 2021
0.14.0
Sep 21, 2021
0.13.0
Sep 20, 2021
0.12.1
Aug 28, 2021
0.12.0
Aug 26, 2021
0.11.3
Aug 09, 2021
0.11.2
Aug 07, 2021
0.11.1
Aug 04, 2021
0.11.0
Aug 03, 2021
0.10.1
Aug 02, 2021
0.10.0
Jul 06, 2021
0.9.2
Jun 02, 2021
0.9.1
May 31, 2021
0.9.0
May 27, 2021
0.8.0
Apr 24, 2021
0.7.0
Apr 17, 2021
0.6.5
Nov 30, 2020
0.6.4
Nov 14, 2020
0.6.3
Nov 11, 2020
0.6.2
Nov 11, 2020
0.6.1
Nov 11, 2020
0.6.0
Oct 24, 2020
0.5.0
Oct 04, 2020
0.4.0
Oct 02, 2020
0.3.1
Sep 16, 2020
0.3.0
Sep 16, 2020
0.2.2
Sep 12, 2020
0.2.1
Sep 11, 2020
0.2.0
Sep 09, 2020
0.1.1
Sep 02, 2020
0.1.0
Aug 30, 2020
0.0.6
Aug 30, 2020
0.0.5
Aug 27, 2020
0.0.4
Aug 27, 2020
0.0.3
Aug 26, 2020