Swarmauri's CroutonClient
CroutonClient is a Python library for streamlined REST API interactions, supporting both synchronous and asynchronous operations for CRUD tasks.
Initialization
from crouton_client import CroutonClient
client = CroutonClient(API_ROOT="https://api.example.com", ACCESS_STRING="your-token")
Common Operations
GET
- Synchronous:
response = client.get(resource="items", item_id="123", filters={"status": "active"})
- Asynchronous:
response = await client.aget(resource="items", item_id="123")
POST
- Synchronous:
response = client.post(resource="items", data_obj={"name": "Item", "price": 10.0})
- Asynchronous:
response = await client.apost(resource="items", data_obj={"name": "Item", "price": 10.0})
PUT
- Synchronous:
response = client.put(resource="items", data_obj={"price": 15.0}, item_id="123")
- Asynchronous:
response = await client.aput(resource="items", data_obj={"price": 15.0}, item_id="123")
DELETE
- Synchronous:
response = client.delete(resource="items", item_id="123")
- Asynchronous:
response = await client.adelete(resource="items", item_id="123")
Features
- Synchronous & Asynchronous: Methods available for GET, POST, PUT, DELETE.
- Authentication: Pass
ACCESS_STRINGfor token-based requests. - Auto-Generated IDs:
postandapostauto-generateidfields if not provided. - Logging: Logs all requests and responses for debugging.
Error Handling
Raises ValueError for failed requests:
try:
client.get(resource="invalid")
except ValueError as e:
print(f"Error: {e}")
Summary Table
| Operation | Synchronous | Asynchronous |
|---|---|---|
| GET | get() |
aget() |
| POST | post() |
apost() |
| PUT | put() |
aput() |
| DELETE | delete() |
adelete() |
CroutonClient simplifies REST API interactions, allowing you to focus on application logic instead of repetitive request handling.
Metadata
Release files for crouton-client 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crouton_client-0.1.6.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crouton_client-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / crouton_client-0.1.6.tar.gz
| Download URL | crouton_client-0.1.6.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f63bf26409c3060da6217b376addcb5d45c6ec8ad09584bdee150ffc7619e102
|
|
BLAKE2b-256 checksum How to use checksums |
945bb0487ff13dd7bab26d171ab696f86bdc7b886d1ea393b806bcf44bcf61d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / crouton_client-0.1.6-py3-none-any.whl
| Download URL | crouton_client-0.1.6-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cad32c1f94b73c451ada91289d324592538ee6ac5d26f904265baa584189f12a
|
|
BLAKE2b-256 checksum How to use checksums |
c0a297c2cadc1d0305979ed6d5316b38331f2f21d34f20edef2078c8916c353b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|