Skip to main content

Parse the raw Stellar data into Python models.

Project description

GitHub Action Read the Docs PyPI Python - Version

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.4

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


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.4.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

stellar_model-0.5.4-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file stellar_model-0.5.4.tar.gz.

File metadata

  • Download URL: stellar_model-0.5.4.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.6 Darwin/23.1.0

File hashes

Hashes for stellar_model-0.5.4.tar.gz
Algorithm Hash digest
SHA256 81024ccd310c8d932f2f361e3bbe90cf459af9f8d517c3db8a032fa0be923785
MD5 102bf9b579b33ca71a1e564cfb83a719
BLAKE2b-256 23f80490018102f67ade8d47d31d06901bb3bf720b40429bf095dcfabd541875

See more details on using hashes here.

File details

Details for the file stellar_model-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: stellar_model-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.6 Darwin/23.1.0

File hashes

Hashes for stellar_model-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 baefa780b59f5fe56153799d7f6d7d324d6ac2c5fa9c12832c3d8973b169ecb6
MD5 097b626ded64666ed92308dd20a418c8
BLAKE2b-256 46a626bf540f0b2a436d2e94bb74485136ed362db8e5df598c09541d0a8f9c5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page