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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for api_client_http-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4d43c75d3e8be8a023c204055cbf87fa7b3b33c5a7d37f0dfab0bdf1115f80f |
|
MD5 | d71f064249b537fa69981ba12c2f3c3c |
|
BLAKE2b-256 | e560ca77de93183c6bf423b05b7ac1923377534564bf1292f6862573a692a33a |