Metadata-Version: 2.1
Name: stellar-model
Version: 0.2.2b0
Summary: Parse the raw Stellar data into Python models.
Home-page: https://github.com/StellarCN/stellar-model
License: Apache-2.0
Keywords: stellar,stellar-model,pydantic
Author: overcat
Author-email: 4catcode@gmail.com
Requires-Python: >=3.6.1
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: pydantic (>=1.8.1,<2.0.0)
Project-URL: Bug Tracker, https://github.com/StellarCN/stellar-mode/issues
Project-URL: Documentation, https://stellar-model.readthedocs.io
Project-URL: Repository, https://github.com/StellarCN/stellar-model
Description-Content-Type: text/x-rst

=============
stellar-model
=============
.. image:: https://img.shields.io/github/workflow/status/StellarCN/stellar-model/GitHub%20Action/main?style=flat&maxAge=1800
    :alt: GitHub Action
    :target: https://github.com/StellarCN/stellar-model/actions

.. image:: https://img.shields.io/readthedocs/stellar-model.svg?style=flat&maxAge=1800
    :alt: Read the Docs
    :target: https://stellar-model.readthedocs.io/en/latest/

.. image:: https://img.shields.io/pypi/v/stellar-model.svg?style=flat&maxAge=1800
    :alt: PyPI
    :target: https://pypi.python.org/pypi/stellar-model

.. image:: https://img.shields.io/badge/Supported%20Horizon%20Version-2.8.3-blue?style=flat
    :alt: Supported Horizon Version
    :target: https://github.com/stellar/go/releases/tag/horizon-v2.8.3

.. image:: https://img.shields.io/badge/python-3.6%20%7C%203.7%20%7C%203.8%20%7C%203.9-blue?style=flat
    :alt: Python - Version
    :target: https://pypi.python.org/pypi/stellar-model

.. image:: https://img.shields.io/badge/implementation-cpython%20%7C%20pypy-blue?style=flat
    :alt: PyPI - Implementation
    :target: https://pypi.python.org/pypi/stellar-model

`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 <https://github.com/StellarCN/stellar-model/issues/20/>`_.

.. code-block:: text

    pip install stellar-model==0.2.2b0

Example
=======
.. code-block:: python

    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`_.

.. code-block:: python

    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


.. _stellar-model: https://github.com/StellarCN/stellar-model
.. _pydantic: https://pydantic-docs.helpmanual.io/
.. _Stellar Horizon: https://developers.stellar.org/api/resources/
.. _stellar-sdk: https://github.com/StellarCN/py-stellar-base
