Parse the raw Stellar data into Python models.
Project description
stellar-model is based on pydantic, you can use it to parse the JSON returned by Stellar Horizon into Python models, through it, you can get a better development experience in the editor with things like code completion, type hints, and more.
Installing
You need to choose a suitable stellar-model version according to the Horizon version number you are using. Please check the list here.
pip install stellar-model==0.5.3
Example
import requests
from stellar_model import AccountResponse
url = "https://horizon.stellar.org/accounts/GALAXYVOIDAOPZTDLHILAJQKCVVFMD4IKLXLSZV5YHO7VY74IWZILUTO"
raw_resp = requests.get(url).json()
parsed_resp = AccountResponse.model_validate(raw_resp)
print(f"Account Sequence: {parsed_resp.sequence}")
Of course you can use it with stellar-sdk.
from stellar_sdk import Server
from stellar_model import AccountResponse
server = Server("https://horizon.stellar.org")
account_id = "GALAXYVOIDAOPZTDLHILAJQKCVVFMD4IKLXLSZV5YHO7VY74IWZILUTO"
raw_resp = server.accounts().account_id(account_id).call()
parsed_resp = AccountResponse.model_validate(raw_resp)
print(f"Account Sequence: {parsed_resp.sequence}")
Documentation
stellar-model’s documentation can be found at https://stellar-model.readthedocs.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stellar_model-0.5.3.tar.gz
(25.3 kB
view hashes)
Built Distribution
Close
Hashes for stellar_model-0.5.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d60697798f80ce5ea973257183ca1854fa40db7096a17034d8f0ed1de69f116 |
|
MD5 | 6c590cdb9681fc247f2a75432d86f13f |
|
BLAKE2b-256 | 3928c6cbd83142254f241d91ff7ef394f7e697bd5f3fb31e0a9ac87e4b99472c |