Skip to main content

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

Project description

PyPI version Python Development Status Maintenance PyPI License


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.5.tar.gz (6.1 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.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyrest_model_client-0.0.5.tar.gz
  • Upload date:
  • Size: 6.1 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.5.tar.gz
Algorithm Hash digest
SHA256 347e0f8cbbccf870f0e67817199e858856158d2549f91f513ba1639d7fe1efc7
MD5 9c1b38ab8eb78c44fb1f44904a03d190
BLAKE2b-256 5bc8b0e929dfa58f7afb105f8e1a3e1c06093ac2b27d363fcde6b1925f608423

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrest_model_client-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0f2141eb864337764ba19ccbd9310c1ea57084c9e7bdb1017d0d40bb1bddb118
MD5 a737c68c8a00c38e48eaed7161d2e5ca
BLAKE2b-256 101c64385638b4916cac9c20e5ab38d0373ded0ffd6fa43c08d516d9dda8dfbb

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