Starlite
Starlite is a light, opinionated and flexible ASGI API framework built on top of pydantic and Starlette.
Check out the Starlite documentation 📚
Core Features
- 👉 Class based controllers
- 👉 Decorators based configuration
- 👉 Extended testing support
- 👉 Extensive typing support including inference, validation and parsing
- 👉 Full async (ASGI) support
- 👉 Layered dependency injection
- 👉 OpenAPI 3.1 schema generation with Redoc UI
- 👉 Route guards based authorization
- 👉 Simple middleware and authentication
- 👉 Support for pydantic models and pydantic dataclasses
- 👉 Support for standard library dataclasses
- 👉 Support for SQLAlchemy declarative classes
- 👉 Plugin system to allow extending supported classes
- 👉 Ultra-fast json serialization and deserialization using orjson
Installation
Using your package manager of choice:
pip install starlite
OR
poetry add starlite
OR
pipenv install starlite
Minimal Example
Define your data model using pydantic or any library based on it (see for example ormar, beanie, SQLModel etc.):
from pydantic import BaseModel, UUID4
class User(BaseModel):
first_name: str
last_name: str
id: UUID4
You can alternatively use a dataclass, either the standard library one or the one from pydantic:
from uuid import UUID
# from pydantic.dataclasses import dataclass
from dataclasses import dataclass
@dataclass
class User:
first_name: str
last_name: str
id: UUID
Define a Controller for your data model:
from typing import List
from pydantic import UUID4
from starlite import Controller, Partial, get, post, put, patch, delete
from my_app.models import User
class UserController(Controller):
path = "/users"
@post()
async def create_user(self, data: User) -> User:
...
@get()
async def list_users(self) -> List[User]:
...
@patch(path="/{user_id:uuid}")
async def partially_update_user(self, user_id: UUID4, data: Partial[User]) -> User:
...
@put(path="/{user_id:uuid}")
async def update_user(self, user_id: UUID4, data: User]) -> User]:
...
@get(path="/{user_id:uuid}")
async def get_user(self, user_id: UUID4) -> User:
...
@delete(path="/{user_id:uuid}")
async def delete_user(self, user_id: UUID4) -> User:
...
Import your controller into your application's entry-point and pass it to Starlite when instantiating your app:
from starlite import Starlite
from my_app.controllers.user import UserController
app = Starlite(route_handlers=[UserController])
To run your application, use an ASGI server such as uvicorn:
uvicorn my_app.main:app --reload
Contributing
Starlite is open to contributions big and small. You can always join our discord server to discuss contributions and project maintenance. For guidelines on how to contribute, please see the contribution guide.
Metadata
Release files for starlite 0.5.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 |
|---|---|---|---|---|
| starlite-0.5.0.tar.gz | 41.1 kB | Without provenance | Details for starlite-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| starlite-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for starlite-0.5.0-py3-none-any.whl |
Total release size: 92.1 kB
Release files / starlite-0.5.0.tar.gz
| Download URL | starlite-0.5.0.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68069865d957b899fcc0fa6c4aacac23036b03282f46680a1e7017121892619b
|
|
BLAKE2b-256 checksum How to use checksums |
df0dff51e8817a5cdd75dbd509f82ae73cdba65edb14ff9585434ed1f275b4b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.10 Linux/5.11.0-1025-azure
|
Release files / starlite-0.5.0-py3-none-any.whl
| Download URL | starlite-0.5.0-py3-none-any.whl |
|---|---|
| Size | 51.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0104a95547e09a1a0153c9c6f9154fbf003db6037a50ee9f9d2414210e66cbf
|
|
BLAKE2b-256 checksum How to use checksums |
879cae6e55b3e8e68030bcb391259f85164dc148ffbd74d2a057a45896cd9122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.10 Linux/5.11.0-1025-azure
|
Security for starlite 0.5.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.