A requests-style SDK for APIs
Project description
Integrates - A requests-style SDK for APIs
Integrates is a Python library providing a simple, ergonomic interface for interacting with various API protocols (REST, GraphQL, SOAP) while maintaining the familiar feel of the Python 'requests' library.
Features
- Simple, Pythonic API: Easy to use with sensible defaults, inspired by the popular
requestslibrary - Protocol Adapters: Support for multiple API protocols with a consistent interface
- Authentication: Built-in support for common authentication methods (Basic, Bearer, API Key, OAuth2)
- Middleware: Extensible middleware system for customizing request/response processing
- Sync and Async Support: Use the same API for both synchronous and asynchronous code
- Strong Typing: Full type annotations for better IDE support and static analysis
- Resilient by Default: Strict timeouts, connection verification, and error handling
Installation
pip install integrates
Quick Start
Basic Usage
import integrates as api
# Create a client
client = api.Client()
# Make a GET request
response = client.get("https://api.example.com/users", params={"page": 1})
print(response.json())
# Make a POST request with JSON data
response = client.post(
"https://api.example.com/users",
json={"name": "John Doe", "email": "john@example.com"}
)
print(f"Status: {response.status_code}")
Async Support
import asyncio
import integrates as api
async def main():
async with api.AsyncClient() as client:
response = await client.get("https://api.example.com/users")
print(response.json())
asyncio.run(main())
Authentication
import integrates as api
from integrates.auth import BearerAuth
# Create a client with token authentication
client = api.Client(
base_url="https://api.example.com",
auth=BearerAuth(token="your_access_token")
)
# All requests will include the Authorization header
response = client.get("/users/me")
Middleware
import integrates as api
from integrates.middleware import RetryMiddleware, LoggingMiddleware
# Create a client with middleware
client = api.Client(
middlewares=[
RetryMiddleware(retries=3),
LoggingMiddleware()
]
)
# Requests will automatically retry on failure and be logged
response = client.get("https://api.example.com/data")
Resource Pattern for REST APIs
import integrates as api
# Create a REST client
client = api.RestClient(base_url="https://api.example.com")
# Create a resource
users = client.resource("users")
# Get all users
all_users = users.get()
# Get a specific user
user = users(123).get()
# Create a user
new_user = users.post(json={"name": "Jane Doe"})
# Update a user
updated_user = users(123).put(json={"name": "Jane Smith"})
# Delete a user
users(123).delete()
Documentation
For more detailed documentation, see the examples directory.
Development
Setup Development Environment
# Clone the repository
git clone https://github.com/caiopizzol/integrates.git
cd integrates
# Install development dependencies
pip install -e ".[dev]"
Run Tests
pytest
License
MIT
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 integrates-0.1.0.tar.gz.
File metadata
- Download URL: integrates-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8291bf27e7cee0aadad66b34f8b1fe82599c65da837946c8d4fccd0a86a9628e
|
|
| MD5 |
5d350a7041345f2c387a5306fc0608d0
|
|
| BLAKE2b-256 |
4b2d853235c09baa0ea78a9e7abe762a33427944b0b287f8de2d1d31c2593a27
|
File details
Details for the file integrates-0.1.0-py3-none-any.whl.
File metadata
- Download URL: integrates-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effedd8153c23b92dfd9522adc0e68e8ca7facd850c4a21dc610c7b5590ef59e
|
|
| MD5 |
aff59c87e308428eefa97c8c092bd92a
|
|
| BLAKE2b-256 |
fcf1f00f8e96b7230a0735da10c96d134a42cb8555293c2d6881cc2f96b61e91
|