Skip to main content

A simple, flexible Python HTTP client and API modeling toolkit built on httpx and pydantic.

Project description

python-requests-client

A simple, flexible Python HTTP client and API modeling toolkit built on top of httpx and pydantic. Easily integrate robust API requests and resource models into your Python projects.


🚀 Features

  • Model-driven: Define and interact with API resources as Python classes.
  • Easy HTTP Requests: Simple RequestClient for GET, POST, PUT, DELETE with automatic header and base URL management.
  • Pydantic API Models: Define resource models with CRUD helpers (save, delete, load, find).
  • Global Client Setup: Set a global API client for all models with set_client().
  • Type Safety: All models use Pydantic for validation and serialization.
  • Extensible: Easily create new models for any RESTful resource.

📦 Installation

pip install python-requests-client

🔧 Usage

1. Define Your Models

from pyrest_model_client.base import BaseAPIModel
from typing import ClassVar


class User(BaseAPIModel):
  name: str
  email: str
  _resource_path: ClassVar[str] = "user"


class Environment(BaseAPIModel):
  name: str
  _resource_path: ClassVar[str] = "environment"

2. Initialize the Client

from pyrest_model_client import RequestClient, build_header, set_client
from example_usage.models.user import User
from example_usage.models.environment import Environment

set_client(
  new_client=RequestClient(
    base_url="http://localhost:8000",
    header=build_header(token="YOUR_API_TOKEN")
  )
)

# Create and save a new user
e = User(name="Alice", email="alice@example.com")
e.save()

# Update and save
e.name = "Alice Smith"
e.save()

# Find all environments
environments = Environment.find()
print(environments)

# Load a specific user by ID
user = User.load(resource_id="123")

# Delete a user
user.delete()

🤝 Contributing

Contributions are welcome! Please fork the repo, create a branch, and submit a pull request.


📄 License

MIT License — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrest_model_client-0.0.3.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrest_model_client-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pyrest_model_client-0.0.3.tar.gz.

File metadata

  • Download URL: pyrest_model_client-0.0.3.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyrest_model_client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8d845f00a7b159615b9aefd06d3d9fd95d4bcf3cf8e8d6985f88e056e5450f12
MD5 f2d5bc65cda2d626637a97f6121e15da
BLAKE2b-256 e6496402c232b5b2d6cbc98bee19019be7cacb36db4c32cf2b28855838d2d763

See more details on using hashes here.

File details

Details for the file pyrest_model_client-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pyrest_model_client-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa45b292213cedb0b241d623d0bc33e2e498a972011a976c6a7cc7f12b3a205a
MD5 937528cdffb9895ae62267cb60617e68
BLAKE2b-256 86a814a71985602fa84bbd5602d8afe35d049b580eccd113232638b68bc9d700

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page