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.
Changelog
v1.1.0
- Updated minimal Python version to
3.11 - Update
httpx:0.21->0.28 - Used
[project]section inpyproject.toml - Used
ruffas default linter
v1.0.0
- First app version
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
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 api_client_http-1.1.0.tar.gz.
File metadata
- Download URL: api_client_http-1.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84af05c2d3e9c79c64214ec1ef0e773973cf536ad0d4b75d4efd5c1c1daf76f8
|
|
| MD5 |
5c7481f2e138b0ae502a7bef0ae31f83
|
|
| BLAKE2b-256 |
166d7d9096eafc52de8712e7cfd6696f1a7310f6bd33d5393bf8da39a33d5e1b
|
File details
Details for the file api_client_http-1.1.0-py3-none-any.whl.
File metadata
- Download URL: api_client_http-1.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd491eba74b2836a843cc5b3a00aeb4e9efe45d71a8e617901ce46a1a252bce4
|
|
| MD5 |
d780d507d0546dbf73b677d16060ffb8
|
|
| BLAKE2b-256 |
f09dcb8e00fbe54f04f6c3fd04845b5fdf26bfda2f6ebbe43ab2124d12fd2055
|