Skip to main content

Parse the raw Stellar data into Python models.

Project description

GitHub Action Read the Docs PyPI Supported Horizon Version Python - Version PyPI - Implementation

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


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.4.0b0.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

stellar_model-0.4.0b0-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file stellar-model-0.4.0b0.tar.gz.

File metadata

  • Download URL: stellar-model-0.4.0b0.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.26.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for stellar-model-0.4.0b0.tar.gz
Algorithm Hash digest
SHA256 00bfc20eb1b97e26b403cd4d41db6ee1fc1a5571d9055706d5f33ac81e262cd3
MD5 4b58822425d1c6659e2d00c1758ae92e
BLAKE2b-256 6e16cc9435d758dbee4430553f932a2a622d243e502a37409aab9ff58b06f9c2

See more details on using hashes here.

File details

Details for the file stellar_model-0.4.0b0-py3-none-any.whl.

File metadata

  • Download URL: stellar_model-0.4.0b0-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.26.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for stellar_model-0.4.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 6395f5f5ccdc2c70f405044ef237e2096c99cc32697804508ff92f04c672a551
MD5 58b7d10ecb768968f0ed4eb47026e7ae
BLAKE2b-256 d0e38270c65451f641cccdcf3cc61078096bfd0544d6b3d973efa4aa1777252a

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