A framework for easy asynchronous HTTP request calling with decorations
Project description
ahttp-client
Using @decorator
to easily request an HTTP Client
This framework based on aiohttp's http client framework.
Use Annotated Type to describe the elements required in an HTTP request.
Installation
Python 3.10 or higher is required.
pip install ahttp-client
Quick Example
An example is the API provided by the BUS API.
import asyncio
import aiohttp
from ahttp_client import request, Session, Query
from typing import Annotated, Any
loop = asyncio.get_event_loop()
class MetroAPI(Session):
def __init__(self, loop: asyncio.AbstractEventLoop):
super().__init__("https://api.yhs.kr", loop=loop)
@request("GET", "/metro/station")
async def station_search_with_query(
self,
response: aiohttp.ClientResponse,
name: Annotated[str, Query]
) -> dict[str, Any]:
return await response.json()
async def main():
async with MetroAPI(loop) as client:
data = await client.station_search_with_query(name="metro-station-name")
print(len(data))
loop.run_until_complete(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
ahttp_client-1.0.1.tar.gz
(15.9 kB
view details)
Built Distribution
File details
Details for the file ahttp_client-1.0.1.tar.gz
.
File metadata
- Download URL: ahttp_client-1.0.1.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8859257980c2281cf94b168a23cec2beda284d01125f390dcc50d15c6c715f76 |
|
MD5 | 7fec564f973827a5bfd6da74e037eb40 |
|
BLAKE2b-256 | 433cbe1d15eb9bc6704627fba39885e170d6b21d2155cfda3355f0f9a1254e4b |
File details
Details for the file ahttp_client-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ahttp_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b544dde51d161fe21434de83dbd0c29248b41a3b25a6f3756720c71bfb2498c |
|
MD5 | f24924a5856729dec8a91f66364b6a54 |
|
BLAKE2b-256 | cb1ccbc7cb04bc21dcf98650fe8dccc04f14ae9a62293c6cfda784241968b18e |