Skip to main content

async_client_decorator is now ahttp-client.

Project description

async-client-decorator

Warning
This package has been renamed from async-client-decorator to ahttp-client
Use pip install ahttp_client instead.

New package: https://pypi.org/p/ahttp-client

PyPI - Version PyPI - Downloads PyPI - License

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

async_client_decorator-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

async_client_decorator-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file async_client_decorator-1.0.0.tar.gz.

File metadata

File hashes

Hashes for async_client_decorator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3ca1a8fb067fdb6ef9875e0ca1637aac11796e4ae163b56154cceb45c1f8c939
MD5 201341d6c15a96b9f0bcb17a4868e308
BLAKE2b-256 1f5f2d87f9d99abf85d40ba04e7f68ebb0c3bec6595507a17af73c54430f4fd2

See more details on using hashes here.

File details

Details for the file async_client_decorator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for async_client_decorator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63ef17685ca25ddacf22563da5e30cb217716549367ed350b666b81f030e02bf
MD5 9e82dab867b24fda6f7b8b5c5019c3d5
BLAKE2b-256 e452d54296acf9b36d1f5be159337652533861a068771e5744301dc58fcfc3f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page