An asynchronous framework to easily build a client-side API
Project description
stollen is an asynchronous framework to easily build a client-side API.
Installation
pip install -U stollen
Example
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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stollen-0.2.14.tar.gz
(13.5 kB
view details)
Built Distribution
stollen-0.2.14-py3-none-any.whl
(15.7 kB
view details)
File details
Details for the file stollen-0.2.14.tar.gz
.
File metadata
- Download URL: stollen-0.2.14.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4918080c578dfe2053df2fd4a9fa94cd745b8cafc24297cca3357915aa09175 |
|
MD5 | 996f1370adb086410e057bce5710820e |
|
BLAKE2b-256 | fc03ac748b2c4429fe913d2c04401b08e8f1d49f2c1592f2ade629626def9902 |
Provenance
The following attestation bundles were made for stollen-0.2.14.tar.gz
:
Publisher:
pypi-release.yml
on py-stollen/stollen
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
stollen-0.2.14.tar.gz
- Subject digest:
c4918080c578dfe2053df2fd4a9fa94cd745b8cafc24297cca3357915aa09175
- Sigstore transparency entry: 146118011
- Sigstore integration time:
- Predicate type:
File details
Details for the file stollen-0.2.14-py3-none-any.whl
.
File metadata
- Download URL: stollen-0.2.14-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | caa09a67e2a2b4cf6de6b97a42d34999c869894d7e6e6ccbc770b6ebdf29fe96 |
|
MD5 | 149e3a75b4118ea0d00aa25007892ffa |
|
BLAKE2b-256 | cdafa49b7c6f8a77573236913f827035c76cef5f97a916cba497338624df1f21 |
Provenance
The following attestation bundles were made for stollen-0.2.14-py3-none-any.whl
:
Publisher:
pypi-release.yml
on py-stollen/stollen
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
stollen-0.2.14-py3-none-any.whl
- Subject digest:
caa09a67e2a2b4cf6de6b97a42d34999c869894d7e6e6ccbc770b6ebdf29fe96
- Sigstore transparency entry: 146118012
- Sigstore integration time:
- Predicate type: