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
pip install stellar-model==0.1.0b1
Example
import requests
from stellar_model import AccountResponse
url = "https://horizon.stellar.org/accounts/GALAXYVOIDAOPZTDLHILAJQKCVVFMD4IKLXLSZV5YHO7VY74IWZILUTO"
raw_resp = requests.get(url).json()
parsed_resp = AccountResponse.parse_obj(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.parse_obj(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.1.0b1.tar.gz
(23.1 kB
view hashes)
Built Distribution
Close
Hashes for stellar_model-0.1.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5938497938afb6c08f8ce4d2cbe44d2496de2853bed84cfda576864f89f6292f |
|
MD5 | 7a89b60d55f7e5a917817833e11bbc65 |
|
BLAKE2b-256 | 1c6151e1e52e7b068517d6425fdc858edee04839e43b5532fb1be9f0ee78205b |