Socket
Socket
Sign inDemoInstall

ahttp-client

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahttp-client

A framework for easy asynchronous HTTP request calling with decorations


Maintainers
1

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 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())

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc