apiclient-wrapper
A lightweight universal HTTP client wrapper with built-in response caching, retry logic, and environment-aware configuration discovery. Simplifies API integration for developers.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- apiclient-wrapper
- author
- dev-toolbox
- license
- MIT
- version
- 1.2.0
- repository
- https://github.com/dev-toolbox/apiclient-wrapper
- api_version
- 1
- description
- A lightweight universal HTTP client wrapper with built-in response caching, retry logic, and environment-aware configuration discovery. Simplifies API integration for developers.
- dependencies
- [ { "python": ">=3.8" }, { "pip": [ "requests>=2.25", "pyyaml>=5.4", "cryptography>=3.4" ] } ]
02 资源文件 6
- 参考文档_provenance.json1.4 KB
- 脚本apiclient_wrapper/__init__.py5.2 KB
- 脚本apiclient_wrapper/cache.py2.5 KB
- 脚本apiclient_wrapper/config.py2.2 KB
- 脚本apiclient_wrapper/exceptions.py277 B
- 参考文档requirements.txt44 B
03 SKILL.md 正文
API Client Wrapper
A minimal, dependency-light HTTP client wrapper designed for rapid prototyping and production use. Provides unified request handling, automatic retries with exponential backoff, and a pluggable response cache.
Features
- Unified request interface –
get,post,put,deletemethods with consistent error handling. - Automatic retry – Transient failures (timeouts, 5xx) retried with exponential backoff.
- Response caching – Optional in-memory or file-based cache to reduce redundant calls.
- Environment-aware config – Reads connection settings from standard environment variables,
.envfiles, or a localconfig.yaml.
Installation
pip install -r requirements.txt
Or install directly from the repository:
pip install git+https://github.com/dev-toolbox/apiclient-wrapper.git
Quick Start
from apiclient_wrapper import Client
client = Client(base_url="https://api.example.com")
response = client.get("/users", params={"limit": 10})
print(response.json())
Configuration
The client automatically discovers configuration from the environment, in this order:
- Environment variables (e.g.,
API_BASE_URL,API_TIMEOUT) - A
.envfile in the current working directory - A
config.yamlfile in the current working directory
Configuration keys:
| Key | Description | Default |
|---|---|---|
base_url |
Base URL for all requests | https://api.example.com |
timeout |
Request timeout in seconds | 30 |
retries |
Number of retry attempts | 3 |
cache_dir |
Directory for file-based response cache | None (disabled) |
Advanced Usage
Custom Headers
client = Client(base_url="...", headers={"Authorization": "Bearer <token>"})
Response Caching
client = Client(base_url="...", cache_dir="./cache")
# Subsequent identical GET requests within TTL (default 300s) return cached responses.
Error Handling
All network-related errors are wrapped in ClientError with a consistent message format.
API Reference
Client(base_url, timeout=30, retries=3, headers=None, cache_dir=None)
Client.get(path, params=None, headers=None)
Client.post(path, json=None, headers=None)
Client.put(path, json=None, headers=None)
Client.delete(path, headers=None)
Development
Run tests with:
python -m pytest tests/
License
MIT
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms