Skip to main content

Client for sync/async query HTTP API Services

Project description

API Client HTTP

Client for sync/async query HTTP API Services. It provides a high-level interface for managing URLs, headers, and authentication. Based on HTTPX library.

Features

  • Synchronous and asynchronous HTTP requests
  • Token-based authentication
  • Customizable headers
  • URL management
  • Error handling

Installation

To install the library, use pip:

pip install api-client-http

Usage

Synchronous client

from api_client_http import RestClient
from api_client_http.auth import TokenAuth

client = RestClient(
    address="https://api.example.com/v1",
    endpoints= {
      'token': 'auth/token',
      'query': 'query/{}'
    }
)

auth_respone = client.post('token', json={'username': 'user', 'password': 'password'})
response = client.get('query', '123', auth=TokenAuth(auth_respone['access_token']))

Asynchronous client

from api_client_http import AsyncRestClient
from api_client_http.auth import TokenAuth

client = AsyncRestClient(
    address="https://api.example.com/v1",
    endpoints= {
      'token': 'auth/token',
      'query': 'query/{}'
    }
)

auth_respone = await client.post('token', json={'username': 'user', 'password': 'password'})
response = await client.get('query', '123', auth=TokenAuth(auth_respone['access_token']))

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

api_client_http-1.0.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

api_client_http-1.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: api_client_http-1.0.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1019-azure

File hashes

Hashes for api_client_http-1.0.0.tar.gz
Algorithm Hash digest
SHA256 64febfed73923698e67d0abae2998724e7eb574ff30b8fb6423bbf4b98cec1f9
MD5 1dbf0a1f03320965ea625eed830e89c7
BLAKE2b-256 dcd5033395cf2145a8f5338102edd1cf27126b10a8b0a3f25b689b76b2b3fd8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: api_client_http-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Linux/6.2.0-1019-azure

File hashes

Hashes for api_client_http-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4d43c75d3e8be8a023c204055cbf87fa7b3b33c5a7d37f0dfab0bdf1115f80f
MD5 d71f064249b537fa69981ba12c2f3c3c
BLAKE2b-256 e560ca77de93183c6bf423b05b7ac1923377534564bf1292f6862573a692a33a

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