Name | stollen JSON |
Version |
0.6.0
JSON |
| download |
home_page | None |
Summary | An asynchronous framework to easily build a client-side API |
upload_time | 2024-12-08 17:36:37 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT |
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/65/62/087b263e4a536d3e656b2428d73558213f98c7757d5b381c985c7d7accf4/stollen-0.6.0.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": "MIT",
"summary": "An asynchronous framework to easily build a client-side API",
"version": "0.6.0",
"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": "ddea58bd0037e2bdffe330f3251a8aa704a12c25db39748130da134928cf2a39",
"md5": "f2792e2ff2460fb8598cc6d3a67ec6ca",
"sha256": "dd2c18ed8871a159714e2d3646ae220dc23f176abce92955be705cf1084313cf"
},
"downloads": -1,
"filename": "stollen-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f2792e2ff2460fb8598cc6d3a67ec6ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 20866,
"upload_time": "2024-12-08T17:36:35",
"upload_time_iso_8601": "2024-12-08T17:36:35.184965Z",
"url": "https://files.pythonhosted.org/packages/dd/ea/58bd0037e2bdffe330f3251a8aa704a12c25db39748130da134928cf2a39/stollen-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6562087b263e4a536d3e656b2428d73558213f98c7757d5b381c985c7d7accf4",
"md5": "b7bf83f4cb1685fa1e70e78307e2f8e5",
"sha256": "e4cbea647cc8c304a24989f5b8029b932f8b311be8dbc6098e3a0fa1c97e8e0e"
},
"downloads": -1,
"filename": "stollen-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "b7bf83f4cb1685fa1e70e78307e2f8e5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16203,
"upload_time": "2024-12-08T17:36:37",
"upload_time_iso_8601": "2024-12-08T17:36:37.233797Z",
"url": "https://files.pythonhosted.org/packages/65/62/087b263e4a536d3e656b2428d73558213f98c7757d5b381c985c7d7accf4/stollen-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-08 17:36:37",
"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"
}