async_client_decorator is now ahttp-client.
Project description
async-client-decorator
Warning
This package has been renamed fromasync-client-decoratorto ahttp-client
Usepip install ahttp_clientinstead.New package: https://pypi.org/p/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 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: Query | str
) -> 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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file async_client_decorator-1.0.0.tar.gz.
File metadata
- Download URL: async_client_decorator-1.0.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ca1a8fb067fdb6ef9875e0ca1637aac11796e4ae163b56154cceb45c1f8c939
|
|
| MD5 |
201341d6c15a96b9f0bcb17a4868e308
|
|
| BLAKE2b-256 |
1f5f2d87f9d99abf85d40ba04e7f68ebb0c3bec6595507a17af73c54430f4fd2
|
File details
Details for the file async_client_decorator-1.0.0-py3-none-any.whl.
File metadata
- Download URL: async_client_decorator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 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 |
63ef17685ca25ddacf22563da5e30cb217716549367ed350b666b81f030e02bf
|
|
| MD5 |
9e82dab867b24fda6f7b8b5c5019c3d5
|
|
| BLAKE2b-256 |
e452d54296acf9b36d1f5be159337652533861a068771e5744301dc58fcfc3f2
|