{"library":"solana","title":"Solana Python API","type":"library","description":"Solana.py is the official Python SDK for interacting with the Solana blockchain. It provides a robust API for building transactions, interacting with the Solana JSON RPC API, and working with the SPL Token Program. The library is actively maintained with frequent releases, often incorporating core types and high-performance components from the `solders` library.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install solana solders"],"cli":null},"imports":["from solana.rpc.async_api import AsyncClient","from solders.keypair import Keypair","from solders.pubkey import Pubkey","from solders.transaction import VersionedTransaction","from solders.message import MessageV0"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://solana.com","github":"https://github.com/michaelhly/solanapy","docs":"https://michaelhly.github.io/solana-py/","changelog":null,"pypi":"https://pypi.org/project/solana/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import asyncio\nimport os\n\nfrom solders.pubkey import Pubkey\nfrom solana.rpc.async_api import AsyncClient\n\nasync def get_sol_balance(public_key_str: str):\n    \"\"\"Fetches the SOL balance of a given public key.\"\"\"\n    # Use a devnet RPC endpoint. For production, consider using a dedicated provider.\n    rpc_url = os.environ.get(\"SOLANA_RPC_URL\", \"https://api.devnet.solana.com\")\n    async with AsyncClient(rpc_url) as client:\n        pubkey = Pubkey.from_string(public_key_str)\n        try:\n            response = await client.get_balance(pubkey)\n            balance_lamports = response.value\n            balance_sol = balance_lamports / 1_000_000_000 # 1 SOL = 1,000,000,000 lamports\n            print(f\"Account: {public_key_str}\")\n            print(f\"Balance: {balance_sol} SOL ({balance_lamports} lamports)\")\n        except Exception as e:\n            print(f\"Error fetching balance: {e}\")\n\nif __name__ == \"__main__\":\n    # Replace with a real Solana public key (e.g., from a test wallet)\n    example_public_key = \"5Q544fFztbO2Drj9yQ9C7M2f8L2rW3e3H5D2n6H6f8f8\" # Example devnet address\n    asyncio.run(get_sol_balance(example_public_key))\n","lang":"python","description":"This quickstart demonstrates how to connect to the Solana Devnet using `AsyncClient` and fetch the SOL balance of a specified public key. It highlights the use of `solders.pubkey.Pubkey` and the asynchronous nature of `solana-py` interactions. Remember to replace the example public key with a valid one and set `SOLANA_RPC_URL` if not using the default devnet endpoint.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.36.12","pypi_latest":"0.36.12","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.9,"avg_import_s":0.37,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.24,"mem_mb":9.9,"disk_size":"48.0M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.9,"import_time_s":0.17,"mem_mb":10,"disk_size":"65M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.38,"mem_mb":11,"disk_size":"50.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.34,"mem_mb":11.1,"disk_size":"67M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.52,"mem_mb":10.9,"disk_size":"42.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.52,"mem_mb":11,"disk_size":"59M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.52,"mem_mb":11.3,"disk_size":"42.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.5,"mem_mb":11.4,"disk_size":"59M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.23,"mem_mb":9.7,"disk_size":"47.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"solana","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.4,"import_time_s":0.24,"mem_mb":9.8,"disk_size":"64M"}]}}