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.0b0

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: stellar-model-0.3.0b0.tar.gz
  • Upload date:
  • Size: 25.0 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

Hashes for stellar-model-0.3.0b0.tar.gz
Algorithm Hash digest
SHA256 f92573e05931882d18699516b835d89a2c7fcbb09fd7f7e06aa44924a89a97ea
MD5 c8046813d2c9fa7cb836057b1a737209
BLAKE2b-256 1973a951959e626653da192dbb3594a77aeae10d689e677d695984e7a44a5deb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stellar_model-0.3.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.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for stellar_model-0.3.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d7ee37556f3c8283235acceb60d1b347538c1ff36e3b46bdb6bc800541f054
MD5 07cefe6220e235cfdc776d230bb08b88
BLAKE2b-256 7120b5bb417e5c7565f17e6c89148a9fc4650037219bbbcbf6d1f598f5798d4b

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