A framework for easy asynchronous HTTP request calling with decorations
Project description
async-client-decorator
Using @decorator
to esaily request an HTTP Client
This framework based on aiohttp's http client framework.
Use Union Type to describe the elements required in an HTTP request.
Installation
Python 3.10 or higher is required.
pip install async-client-decorator
Quick Example
An example is the API provided by the BUS API.
import asyncio
import aiohttp
from async_client_decorator import request, Session, Query
loop = asyncio.get_event_loop()
class BusAPI(Session):
def __init__(self, loop: asyncio.AbstractEventLoop):
super().__init__("https://api.yhs.kr", loop)
@request("GET", "/bus/station")
async def station_search_with_query(
self,
response: aiohttp.ClientResponse,
name: Query | str
):
return await response.json()
async def main():
async with BusAPI(loop) as client:
response = await client.station_search_with_query(name="bus-station-name")
data = await response.json()
print(len)
loop.run_until_complete(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for async_client_decorator-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f3c5113c8c37d9a735a3db075c3fd8b60b61a7eb60dbae96791e571e8bf1aa |
|
MD5 | 5a4f71b0dacfc98b92b7abb5896c313a |
|
BLAKE2b-256 | 4284ab474287db4a45ba54b597c404cf4ce43f7e3c70f44b2f761cfdee37b712 |
Close
Hashes for async_client_decorator-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c25270f7bbea237e5ea9d533cc143a1bb3b3c8e97094f74ef2e1dbbf9915e0d |
|
MD5 | cb6c1e6548a175397c1781c5dd3f2c8c |
|
BLAKE2b-256 | 74c647a437cd9bc9111e49acd8523db67650d6d8298f43b15994acb0e7bd1a2e |