APIToolbox
Full-stack, asynchronous Python3 framework.
Design goals
- Fast, full-service framework
- Modular approach that does not force any design decisions
Getting started
from fastapi import FastAPI, Request
from apitoolbox import crud, db_registry
from apitoolbox.middleware import SessionMiddleware
from apitoolbox.models import BASE, Session, User
DATABASE_URL = "sqlite:///sqlite.db?check_same_thread=False"
# Define our model
class MyUser(User):
pass
# Instantiate the application
app = FastAPI()
app.add_middleware(SessionMiddleware, bind=DATABASE_URL)
# Create all tables
bind = db_registry.get_or_create(DATABASE_URL)
BASE.metadata.create_all(bind=bind)
# Load some data
session = Session()
for name in ["alice", "bob", "charlie", "david"]:
user = MyUser.get_by_username(session, name)
if user is None:
user = MyUser(username=name)
session.add(user)
session.commit()
# Add an endpoint
@app.get("/users")
async def list_users(
request: Request
):
return await crud.list_instances(MyUser, request.state.session)
Assuming the above code is stored in the file main.py, then run it via:
uvicorn main:app --reload
Call the endpoint:
curl -s localhost:8000/users | jq .
The output should contain a list of 4 users,
each with the attributes id, username, updated_at and created_at.
Metadata
Release files for apitoolbox 0.12.0
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 | Actions |
|---|---|---|---|---|
| apitoolbox-0.12.0.tar.gz | 26.8 kB | Without provenance | Details for apitoolbox-0.12.0.tar.gz |
Release files / apitoolbox-0.12.0.tar.gz
| Download URL | apitoolbox-0.12.0.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
023fe13065781aedfa12a90b69311462ff14617f2c8260f0fc3affad302bd103
|
|
BLAKE2b-256 checksum How to use checksums |
16228d1a1554a92f19d58a66ec3461ff9a02f705274fe28625d52e79c2034465
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
|
Security for apitoolbox 0.12.0
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.