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.2.1b0
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
Built Distribution
File details
Details for the file stellar-model-0.2.1b0.tar.gz
.
File metadata
- Download URL: stellar-model-0.2.1b0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35e5950bb4caebf63248a73b45a97c10fb95f1561f8af968363b82ecd85259e6 |
|
MD5 | 05eeb0a92cb18ab90e9d9358121b9bf8 |
|
BLAKE2b-256 | 8f9f126ae4675b6257f1ebec6adc445a1cca4802d5368d27c2f014f17ce9a4c6 |
File details
Details for the file stellar_model-0.2.1b0-py3-none-any.whl
.
File metadata
- Download URL: stellar_model-0.2.1b0-py3-none-any.whl
- Upload date:
- Size: 43.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 149c2d9fbc1002d85a587b6cbfb9ea0a4d8a745b2303d97a58f3aed8075b1546 |
|
MD5 | f0bcc6e60aaf091635ba4c3cf7e3191f |
|
BLAKE2b-256 | 4232a1fa3d9928ad1c57014c1688c8b0499b690b0cf571b239ae690e942f1a4c |