Metadata-Version: 2.3
Name: stollen
Version: 0.1.2
Summary: An asynchronous framework to easily build a client-side API
Project-URL: Repository, https://github.com/wakaree/stollen
Author: nullmatawasoradesu
Maintainer: nullmatawasoradesu
License-Expression: MIT
License-File: LICENSE
Keywords: api,asyncio,client,framework,wrapper
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Framework :: AsyncIO
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: aiohttp~=3.9.0
Requires-Dist: certifi==2023.11.17
Requires-Dist: pydantic<2.6,>=2.4.1
Provides-Extra: dev
Requires-Dist: black~=23.12.1; extra == 'dev'
Requires-Dist: mypy~=1.9.0; extra == 'dev'
Requires-Dist: pre-commit~=3.6.0; extra == 'dev'
Requires-Dist: ruff~=0.1.11; extra == 'dev'
Description-Content-Type: text/x-rst


#######
stollen
#######

**stollen** is an asynchronous framework to easily build a client-side API.

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",
                use_method_placeholders=True,
                error_message_key=["status", "error_message"],
                general_error_class=CoingeckoAPIError,
                error_codes={429: RateLimitError},
            )

        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.INFO)
        async with Coingecko() as coingecko:
            gecko_says: GeckoSays = await coingecko.ping()
            logging.info(gecko_says)


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