stollen


Namestollen JSON
Version 0.6.5 PyPI version JSON
download
home_pageNone
SummaryAn asynchronous framework to easily build a client-side API
upload_time2025-01-11 14:40:24
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords api asyncio client framework wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
#######
stollen
#######

.. image:: https://img.shields.io/pypi/l/stollen.svg?style=flat-square
    :target: https://opensource.org/licenses/MIT
    :alt: MIT License

.. image:: https://img.shields.io/pypi/status/stollen.svg?style=flat-square
    :target: https://pypi.python.org/pypi/stollen
    :alt: PyPi status

.. image:: https://img.shields.io/pypi/v/stollen.svg?style=flat-square
    :target: https://pypi.python.org/pypi/stollen
    :alt: PyPi Package Version

.. image:: https://img.shields.io/pypi/dm/stollen.svg?style=flat-square
    :target: https://pypistats.org/packages/stollen
    :alt: Downloads

.. image:: https://img.shields.io/pypi/pyversions/stollen.svg?style=flat-square
    :target: https://pypi.python.org/pypi/stollen
    :alt: Supported python versions

**Stollen** is an asynchronous framework designed to streamline the process
of building API clients, written in Python 3.9+ using
`aiohttp <https://github.com/aio-libs/aiohttp>`_ and
`pydantic <https://docs.pydantic.dev/latest/>`_.
With a declarative approach, Stollen allows developers
to define API methods, handle responses, and manage errors
in a structured way, focusing on clarity and scalability.

Installation
------------

..  code-block:: bash

    pip install -U stollen

Example
-------

.. code-block:: python

    from __future__ import annotations

    import asyncio
    import logging

    from stollen import Stollen, StollenMethod, StollenObject
    from stollen.enums import HTTPMethod
    from stollen.exceptions import StollenAPIError


    class CoingeckoAPIError(StollenAPIError):
        pass


    class RateLimitError(CoingeckoAPIError):
        pass


    class Coingecko(Stollen):
        def __init__(self) -> None:
            super().__init__(
                base_url="https://api.coingecko.com/api/v3",
                error_message_key=["status", "error_message"],
                general_error_class=CoingeckoAPIError,
                error_codes={429: RateLimitError},
                stringify_detailed_errors=False,
            )

        async def ping(self) -> GeckoSays:
            call: Ping = Ping()
            return await self(call)


    class GeckoSays(StollenObject[Coingecko]):
        gecko_says: str


    class Ping(
        StollenMethod[GeckoSays, Coingecko],
        http_method=HTTPMethod.GET,
        api_method="/ping",
        returning=GeckoSays,
    ):
        pass


    async def main() -> None:
        logging.basicConfig(level=logging.DEBUG)
        async with Coingecko() as coingecko:
            gecko_says: GeckoSays = await coingecko.ping()
            logging.info(gecko_says)


    if __name__ == "__main__":
        asyncio.run(main())

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "stollen",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "wakaree <nullmatawasoradesu@gmail.com>",
    "keywords": "api, asyncio, client, framework, wrapper",
    "author": null,
    "author_email": "wakaree <nullmatawasoradesu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bf/33/8335de9fe2cb719b16091f6097d6b7b5c46fd052d067286da2ba01f7d916/stollen-0.6.5.tar.gz",
    "platform": null,
    "description": "\n#######\nstollen\n#######\n\n.. image:: https://img.shields.io/pypi/l/stollen.svg?style=flat-square\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n.. image:: https://img.shields.io/pypi/status/stollen.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/stollen\n    :alt: PyPi status\n\n.. image:: https://img.shields.io/pypi/v/stollen.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/stollen\n    :alt: PyPi Package Version\n\n.. image:: https://img.shields.io/pypi/dm/stollen.svg?style=flat-square\n    :target: https://pypistats.org/packages/stollen\n    :alt: Downloads\n\n.. image:: https://img.shields.io/pypi/pyversions/stollen.svg?style=flat-square\n    :target: https://pypi.python.org/pypi/stollen\n    :alt: Supported python versions\n\n**Stollen** is an asynchronous framework designed to streamline the process\nof building API clients, written in Python 3.9+ using\n`aiohttp <https://github.com/aio-libs/aiohttp>`_ and\n`pydantic <https://docs.pydantic.dev/latest/>`_.\nWith a declarative approach, Stollen allows developers\nto define API methods, handle responses, and manage errors\nin a structured way, focusing on clarity and scalability.\n\nInstallation\n------------\n\n..  code-block:: bash\n\n    pip install -U stollen\n\nExample\n-------\n\n.. code-block:: python\n\n    from __future__ import annotations\n\n    import asyncio\n    import logging\n\n    from stollen import Stollen, StollenMethod, StollenObject\n    from stollen.enums import HTTPMethod\n    from stollen.exceptions import StollenAPIError\n\n\n    class CoingeckoAPIError(StollenAPIError):\n        pass\n\n\n    class RateLimitError(CoingeckoAPIError):\n        pass\n\n\n    class Coingecko(Stollen):\n        def __init__(self) -> None:\n            super().__init__(\n                base_url=\"https://api.coingecko.com/api/v3\",\n                error_message_key=[\"status\", \"error_message\"],\n                general_error_class=CoingeckoAPIError,\n                error_codes={429: RateLimitError},\n                stringify_detailed_errors=False,\n            )\n\n        async def ping(self) -> GeckoSays:\n            call: Ping = Ping()\n            return await self(call)\n\n\n    class GeckoSays(StollenObject[Coingecko]):\n        gecko_says: str\n\n\n    class Ping(\n        StollenMethod[GeckoSays, Coingecko],\n        http_method=HTTPMethod.GET,\n        api_method=\"/ping\",\n        returning=GeckoSays,\n    ):\n        pass\n\n\n    async def main() -> None:\n        logging.basicConfig(level=logging.DEBUG)\n        async with Coingecko() as coingecko:\n            gecko_says: GeckoSays = await coingecko.ping()\n            logging.info(gecko_says)\n\n\n    if __name__ == \"__main__\":\n        asyncio.run(main())\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "An asynchronous framework to easily build a client-side API",
    "version": "0.6.5",
    "project_urls": {
        "Issues": "https://github.com/py-stollen/stollen/issues",
        "Source": "https://github.com/py-stollen/stollen"
    },
    "split_keywords": [
        "api",
        " asyncio",
        " client",
        " framework",
        " wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb968e3ddf14b88c75e1ad08e0c9225f08857e8022b31b36a8aff93f4e7aafa7",
                "md5": "cf6259736737143c67057b40d62d3c8b",
                "sha256": "7f0d96f1cc19291261bbb69335ae721701cbd30fe2413dc217bd118358df65e9"
            },
            "downloads": -1,
            "filename": "stollen-0.6.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cf6259736737143c67057b40d62d3c8b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21034,
            "upload_time": "2025-01-11T14:40:21",
            "upload_time_iso_8601": "2025-01-11T14:40:21.428607Z",
            "url": "https://files.pythonhosted.org/packages/eb/96/8e3ddf14b88c75e1ad08e0c9225f08857e8022b31b36a8aff93f4e7aafa7/stollen-0.6.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf338335de9fe2cb719b16091f6097d6b7b5c46fd052d067286da2ba01f7d916",
                "md5": "e780efe177fff31a68858b93e7a63582",
                "sha256": "b8ecb8c84d96f71a8a541cb3b96378f49804ceb851f2d38b9ae6fc96809847f4"
            },
            "downloads": -1,
            "filename": "stollen-0.6.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e780efe177fff31a68858b93e7a63582",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16364,
            "upload_time": "2025-01-11T14:40:24",
            "upload_time_iso_8601": "2025-01-11T14:40:24.103870Z",
            "url": "https://files.pythonhosted.org/packages/bf/33/8335de9fe2cb719b16091f6097d6b7b5c46fd052d067286da2ba01f7d916/stollen-0.6.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-11 14:40:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "py-stollen",
    "github_project": "stollen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stollen"
}
        
Elapsed time: 0.57399s