A Python client for interacting with a REST API
Project description
Proxy API Documentation
Overview
The Proxy API is a Python client for interacting with a REST API. It provides a simple interface for performing CRUD operations and supports authentication via JWT.
Features
- Authentication using JWT
- CRUD operations for various resources
- Filtering and excluding resources
- Error handling with logging
Installation
To use the Proxy API, simply copy the code into your Python environment. Ensure you have the required dependencies installed:
pip install requests pandas
Usage
Initialization
Initialize the APIClient with the base URL of your API. You can also pass an optional token for authentication.
from api_client import APIClient
# Initialize the API client
client = APIClient(base_url='http://localhost:3000')
# Authenticate (if required)
client.login(email="john@example.com", password="secret")
Resource Operations
The APIClient initializes proxies for various resources. You can perform operations like fetching all resources, filtering, and excluding specific IDs.
# Get all users
users = client.user.all()
# Get users from ID 1 to 10
users_range = client.user.all()[1:11]
# Exclude users with IDs 7, 8, 9 and get all reamining users
users_excluded = client.user.exclude([7, 8, 9])
# Filter stations by date range
stations = client.station.filter(start_date="2025-01-01", end_date="2025-12-31")
Error Handling
The API client logs errors and raises exceptions when API requests fail. This ensures that issues are bubbled up to the caller for handling.
API Reference
Classes
APIClient: Main client for interacting with the API. Handles authentication and resource operations.ResourceProxy: Proxy for performing operations on a specific resource. Supports CRUD operations and filtering.
Methods
APIClient.login(email: str, password: str): Authenticate and obtain a JWT token.ResourceProxy.all(): Fetch all resources.ResourceProxy.get(id: Union[int, str]): Fetch a single resource by ID.ResourceProxy.filter(**kwargs): Filter resources by query parameters.ResourceProxy.exclude(ids: List[int]): Fetch all resources excluding specified IDs.
License
This project is licensed under the MIT License.
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 proxy_api_package-0.1.1.tar.gz.
File metadata
- Download URL: proxy_api_package-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32804ff141c5d16b561c56270087b7f7f5acfd91e3d922a7a91f093fa069057a
|
|
| MD5 |
0e5bd9dd916aafdb8e4e3e85832849f6
|
|
| BLAKE2b-256 |
d73f0315f3dd8289dcd04d65a67f1742b1e802cb6decd709c9421bd7cff18d1d
|
File details
Details for the file proxy_api_package-0.1.1-py3-none-any.whl.
File metadata
- Download URL: proxy_api_package-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
328914e2795d8ad83da197d7e6e5f0d84752b9cbe807c11bbcf7b39a8f83c9d1
|
|
| MD5 |
f1a982ae21309e71aa5bb1bf9c56dd2e
|
|
| BLAKE2b-256 |
355b7915d3ad0dd43d307be9de9bc2188958295c58464ac71cac5f7f86222602
|