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
Schema
from pydantic import BaseModel
class Product(BaseModel):
id: int | None = None
name: str
description: str
code: str
Serializer
from resty.serializers import Serializer
class ProductSerializer(Serializer):
schema = Product
Manager
from resty.enums import (
Endpoint,
Field
)
from resty.managers import Manager
class ProductManager(Manager):
serializer = ProductSerializer
endpoints = {
Endpoint.CREATE: '/products/',
Endpoint.READ: '/products/',
Endpoint.READ_ONE: '/products/{pk}/',
Endpoint.UPDATE: '/products/{pk}/',
Endpoint.DELETE: '/products/{pk}/',
}
fields = {
Field.PRIMARY: 'id',
}
CRUD
from httpx import AsyncClient
from resty.clients.httpx import RESTClient
async def main():
xclient = AsyncClient(base_url='http://localhost:8000/')
rest_client = RESTClient(xclient=xclient)
product = Product(
name='First prod',
description='My Desc',
code='123W31Q'
)
# Create
created = await ProductManager.create(rest_client, product)
# Read
my_product = await ProductManager.read_one(rest_client, created.id)
for prod in await ProductManager.read(rest_client):
print(prod.name)
# Update
my_product.description = 'QWERTY'
await ProductManager.update(rest_client, my_product)
# Delete
await ProductManager.delete(rest_client, my_product.id)
Status
0.0.4 - 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.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| resty_client-0.0.4.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| resty_client-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.2 kB
Release files / resty_client-0.0.4.tar.gz
| Download URL | resty_client-0.0.4.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
568dbc876384bd8c7e16e09592eafab9f6f417dcbd42d4df04d4bab611813726
|
|
BLAKE2b-256 checksum How to use checksums |
c408de3220d4bb4a52222fa4c50ee2a46aeceaf722a9fc6a270cd16a0b6a43ed
|
| 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.4-py3-none-any.whl
| Download URL | resty_client-0.0.4-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c1ab45c8b42852ff1a96237f8046c959eb08a56bb1f739b1201644fa60fa1e42
|
|
BLAKE2b-256 checksum How to use checksums |
42d646f766d81e7fec42212124502ef07d36458d6dd535824afe74454b744a6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.1 Windows/10
|