Name | stollen JSON |
Version |
0.6.6
JSON |
| download |
home_page | None |
Summary | An asynchronous framework to easily build a client-side API |
upload_time | 2025-02-02 09:43:40 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
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/47/38/7d580b3774c7db23e8849572d32d92489ab59d1365092223ffe39204b58b/stollen-0.6.6.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.6",
"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": null,
"digests": {
"blake2b_256": "0106ee6137a658d278c4ad832360a1c6e42b4a36a70a1edfa7c4cc450714fa17",
"md5": "06f1f87b546b1b1065a0ed4b2660ea7f",
"sha256": "d52e16185faee190adc63f954994daf47094bb0287c29bba187105e2c529c9d0"
},
"downloads": -1,
"filename": "stollen-0.6.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "06f1f87b546b1b1065a0ed4b2660ea7f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21127,
"upload_time": "2025-02-02T09:43:38",
"upload_time_iso_8601": "2025-02-02T09:43:38.250418Z",
"url": "https://files.pythonhosted.org/packages/01/06/ee6137a658d278c4ad832360a1c6e42b4a36a70a1edfa7c4cc450714fa17/stollen-0.6.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "47387d580b3774c7db23e8849572d32d92489ab59d1365092223ffe39204b58b",
"md5": "68f3c60097085bfe05491787d850f7a8",
"sha256": "7930a02a06a3f3aafbea111966e586a75578cf14513464f765ea73ff2650b3c8"
},
"downloads": -1,
"filename": "stollen-0.6.6.tar.gz",
"has_sig": false,
"md5_digest": "68f3c60097085bfe05491787d850f7a8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16463,
"upload_time": "2025-02-02T09:43:40",
"upload_time_iso_8601": "2025-02-02T09:43:40.399172Z",
"url": "https://files.pythonhosted.org/packages/47/38/7d580b3774c7db23e8849572d32d92489ab59d1365092223ffe39204b58b/stollen-0.6.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-02 09:43:40",
"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"
}