Skip to main content

WebTool(Alpha)

Well-Architected FastAPI/Starlette library for JWT authentication, throttling, caching, logging, and utilities.

Requirements

  • Python 3.11+

Installation

pip install webtool
poetry add webtool

Features

Authentication

JWT token management system with Redis-backed refresh tokens.

from webtool.auth import JWTService
from webtool.cache import RedisCache

cache_client = RedisCache("redis://localhost:6379/0")
jwt_service = JWTService(cache_client)


async def get_token():
    access, refresh = jwt_service.create_token({"sub": 123, "scope": ["write"]})
    return access, refresh

Throttling

Rate limiting system for FastAPI/Starlette applications.

from fastapi import FastAPI
from starlette.middleware import Middleware
from webtool.auth import JWTService
from webtool.cache import RedisCache
from webtool.throttle import limiter, LimitMiddleware, JWTBackend

cache = RedisCache("redis://127.0.0.1:6379/0")
jwt_backend = JWTBackend(JWTService(cache, secret_key="test"))

app = FastAPI(
    middleware=[
        Middleware(
            LimitMiddleware,
            cache=cache,
            auth_backend=jwt_backend,
        ),
    ],
)


@app.get("/api/resource")
@limiter(max_requests=50, interval=3600, scopes=["user"])
@limiter(max_requests=10, interval=3600, scopes=["anno"])
async def get_resource():
    return {"status": "success"}

MsgPack Response

MessagePack-based response.

from webtool.utils import MsgSpecJSONResponse
from fastapi import FastAPI

app = FastAPI(
    default_response_class=MsgSpecJSONResponse,
)


@app.get("/api/resource")
async def get_resource():
    return {"status": "success"}

License

This project is licensed under the Apache-2.0 License.

Metadata

Release files for webtool 0.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for webtool 0.1.14
File Size Uploaded
webtool-0.1.14.tar.gz 24.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for webtool 0.1.14
File Interpreter ABI Platform
webtool-0.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 56.7 kB

Release files / webtool-0.1.14.tar.gz

Download URL webtool-0.1.14.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5c11ca1e2dc3486fb1029da77d47acc5adffac84e640ded4965883daf1d49464
BLAKE2b-256 checksum
How to use checksums
11c22b38aa345c52260597322dd8b22c1d90edf8b2b7e51a121b3acfb593951a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.4 Linux/6.11.0-1015-azure

Release files / webtool-0.1.14-py3-none-any.whl

Download URL webtool-0.1.14-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd13d93b716b3ff35e626971ab052c92df1aa07e4de495d9a63183eb58e4e427
BLAKE2b-256 checksum
How to use checksums
0ab1e81d0493691e5ecd0732d614bafea925b27422182db13f27665727d4f59f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.13.4 Linux/6.11.0-1015-azure

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page