SolSystem
Friendly Solana RPC API client supporting both Http and Websockets.
Includes some endpoints specific only to Helius and the Metaplex DAAS API for retrieving asset data.
Why + Plans
After trying the official solana python + solders packages I was left feeling like they were an afterthought of development and weren't supported too well. The API wasn't to my liking, so I decided to develop something more pythonic and cleaner.
As I work on solana projects I plan to add further functionality to this API. One of the goals is to integrate a DEX API as well, likely from jupiter.
Version Note
This API was built with Python 3.12 and the latest package versions available at the time. The purpose was to take advantage of the great typing additions that have come to python and pydantic up to version 3.12. The library can fairly easily be backported to earlier versions of python, but it was not in the current scope of the author's work.
Examples
Using the SyncClient to return account info for a particular public key. Common configuration parameters are provided via the Configuration Object. The response object here will be a fully typed solsystem Response object with populated fields.
from SolSystem import (
SyncClient,
GetAccountInfo,
Configuration,
Encoding,
)
def main():
with SyncClient(rpc_endpoint = "<RPC ENDPOINT URL>") as client:
response = client.request(
method = GetAccountInfo(
account = "<BASE58 PUBLIC KEY>",
configuration = Configuration(
encoding = Encoding.JSONPARSED,
)
)
)
# Note response is fully typed as a Response[Account] object
print(response.model_dump_json(indent = 2))
Here we use the AsyncClient to get the current account balance and display the balance in both SOL and Lamports. We can use the Lamports response object to easily convert and perform arithmetic operations on the value.
import asyncio
from SolSystem import (
AsyncClient,
GetAccountBalance,
Configuration,
Commitment,
)
async def main():
async with AsyncClient(rpc_endpoint = "<RPC ENDPOINT URL>") as client:
resopnse = await client.request(
method = GetAccountBalance(
account = "<BASE58 PUBLIC KEY>",
configuration = Configuration(
commitment = Commitment.CONFIRMED,
)
)
)
# Note response is fully typed as a Response[Lamports] object
print(response.model_dump_json(indent = 2))
print(F"Lamport Value: {response.value}")
print(F"Sol Value: {response.value.sol}")
The Websocket client works as a factory which creates subscribed clients. Each call to subscribe on the factory will create a separate object that manages the subscription for its specific method. We then use an async iterator or a loop to receive messages on each subscription.
import asyncio
from SolSystem import (
WebsocketClient,
WsGetAccountInfo,
Configuration,
Commitment,
)
async def main():
async with WebsocketClient(
end_point = "<WS RPC ENDPOINT URL>",
message_limit = 3,
) as client_factory:
# We will only recieve 3 messages per subscription
account_subscription = await client_factory.subscribe(
method = WsGetAccountInfo(
account = "<BASE58 PUBLIC KEY>",
configuration = Configuration(
commitment = Commitment.FINALIZED,
)
)
)
async for message in account_subscription:
print(F"Owner: {message.value.owner}")
print(F"Balance: {message.value.lamports}")
print(F"Data: {message.value.data}")
await account_subscription.unsubscribe()
Development
The project uses pdm as both the package manager and the build tool for simplicity. For development simply pull and run pdm install provided you have the correct python version and pdm installed already.
Simple tests are available in the /tests/ folder for confirming that response and request models are working correctly.
The project was developed in an environment running ruff and pylance so type checking was done through them.
Metadata
Release files for solsystem 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| solsystem-1.0.8.tar.gz | 62.1 kB | Without provenance | Details for solsystem-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| solsystem-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for solsystem-1.0.8-py3-none-any.whl |
Total release size: 174.1 kB
Release files / solsystem-1.0.8.tar.gz
| Download URL | solsystem-1.0.8.tar.gz |
|---|---|
| Size | 62.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
776fc624e48e062d77c9d6db3c6928975716fa44217bd97b1db5899ab0fcb653
|
|
BLAKE2b-256 checksum How to use checksums |
b09e386ec0ba6f57eb17c858c576ab8d58666ede4502e61d3e45efefa7853649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.19.2 CPython/3.13.0 Darwin/22.1.0
|
Release files / solsystem-1.0.8-py3-none-any.whl
| Download URL | solsystem-1.0.8-py3-none-any.whl |
|---|---|
| Size | 112.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
782dbb52bc3096e6706a782fca474b38c63a7139952e08c9a79d9a0bd4a4a16c
|
|
BLAKE2b-256 checksum How to use checksums |
089276506fcaaf5fb2ed03bb352f0f06e16af0a1902412b97fe4b84140bfb814
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.19.2 CPython/3.13.0 Darwin/22.1.0
|
Security for solsystem 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.