Resty-Client
Resty-Client is a simple, easy-to-use Python library for interacting with REST APIs using Pydantic's powerful data validation and deserialization tools. This library provides an intuitive API that makes it easy to make HTTP requests and handle data on the client side.
Features
- Middleware system, which allows you to implement any pagination, filtering or authentication.
- Powerful data validation & deserialization using Pydantic
- Easy-to-Use
Installation
Using pip:
pip install resty-client
Using Poetry:
poetry add resty-client
Getting-Started
See examples for more.
Schemas
from resty.types import Schema
class UserCreateSchema(Schema):
username: str
email: str
password: str
age: int
class UserReadSchema(Schema):
id: int
username: str
email: str
age: int
class UserUpdateSchema(Schema):
username: str = None
email: str = None
Manager
from resty.managers import Manager
from resty.enums import Endpoint, Field
class UserManager(Manager):
endpoints = {
Endpoint.CREATE: "users/",
Endpoint.READ: "users/",
Endpoint.READ_ONE: "users/{pk}",
Endpoint.UPDATE: "users/{pk}",
Endpoint.DELETE: "users/{pk}",
}
fields = {
Field.PRIMARY: "id",
}
CRUD
import asyncio
import httpx
from resty.clients.httpx import RESTClient
async def main():
client = RESTClient(httpx.AsyncClient(base_url="https://localhost:8000"))
manager = UserManager(client=client)
response = await manager.create(
obj=UserCreateSchema(
username="admin",
email="admin@admin.com",
password="admin",
age=19,
),
response_type=UserReadSchema,
)
print(response) # id=1 username='admin' email='admin@admin.com' age=19
response = await manager.read(
response_type=UserReadSchema,
)
for obj in response:
print(obj) # id=1 username='admin' email='admin@admin.com' age=19
response = await manager.read_one(
obj_or_pk=1,
response_type=UserReadSchema,
)
print(response) # id=1 username='admin' email='admin@admin.com' age=19
response = await manager.update(
obj=UserUpdateSchema(
id=1,
username="admin123",
),
response_type=UserReadSchema,
)
print(response) # id=1 username='admin123' email='admin@admin.com' age=19
await manager.delete(
obj_or_pk=1,
expected_status=204,
)
if __name__ == "__main__":
asyncio.run(main())
Status
0.0.5 - RELEASED
Licence
Resty-Client is released under the MIT License. See the bundled LICENSE file for details.
Metadata
Release files for resty-client 0.0.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 | Provenance | |
|---|---|---|---|---|
| resty_client-0.0.6.tar.gz | 10.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| resty_client-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.4 kB
Release files / resty_client-0.0.6.tar.gz
| Download URL | resty_client-0.0.6.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5bc8a40f54bcf6a338f276245152249bfcb601f9c2bfc8da79c82a73796d404
|
|
BLAKE2b-256 checksum How to use checksums |
a6b95d959bfdb3542abaa05b03a842b34376f53a9581e2aab439e1b0c7a8e95a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.1 Windows/10
|
Release files / resty_client-0.0.6-py3-none-any.whl
| Download URL | resty_client-0.0.6-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73a0437e5a5139244c23572300143847d2148f99a2ebb3e38e8e65db28729726
|
|
BLAKE2b-256 checksum How to use checksums |
b90fa524e491a02db3865c88e8cd461841df82e47738e862f5c2539bf17ca91e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.1 Windows/10
|
Security for resty-client 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.