Skip to main content

Penta - A web framework for building APIs with Django and Python type hints.

Project description

Fast to learn, fast to code, fast to run

Test Coverage PyPI version Downloads

Penta - Fast Django REST Framework

Penta is a web framework for building APIs with Django and Python 3.10+ type hints.

Key features:

  • Easy: Designed to be easy to use and intuitive.
  • FAST execution: Very high performance thanks to Pydantic and async support.
  • Fast to code: Type hints and automatic docs lets you focus only on business logic.
  • Dependency injection
  • Standards-based: Based on the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
  • Django friendly: (obviously) has good integration with the Django core and ORM.

Documentation: As Penta is a fork of django ninja, you can start here. We will create a dedicated documentation for Penta soon !


Installation

pip install penta

Usage

In your django project next to urls.py create new api.py file:

from penta import Penta

api = Penta()


@api.get("/add")
def add(request, a: int, b: int):
    return {"result": a + b}

Now go to urls.py and add the following:

...
from .api import api

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/", api.urls),  # <---------- !
]

That's it !

Now you've just created an API that:

  • receives an HTTP GET request at /api/add
  • takes, validates and type-casts GET parameters a and b
  • decodes the result to JSON
  • generates an OpenAPI schema for defined operation

Interactive API docs

Now go to http://127.0.0.1:8000/api/docs

You will see the automatic interactive API documentation (provided by Swagger UI or Redoc):

Swagger UI

What next?

Download files

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

Source Distribution

penta-0.3.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

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

penta-0.3.2-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file penta-0.3.2.tar.gz.

File metadata

  • Download URL: penta-0.3.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for penta-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1abafc8f4c011a4953faf1c62fd9045bed4b4cf6db20eb89512f112f4a72bb0c
MD5 bfe2d2ccce2212a0c8b2530744e38b8c
BLAKE2b-256 955e18a373a0539e095ef66badce30ea8904cce2a1f43f9fe9e578b0e80cda33

See more details on using hashes here.

File details

Details for the file penta-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: penta-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for penta-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 93c7b9289d32a49fa9951b946f36f8148afd75dc84fc5f484713d9092bf19dc8
MD5 f630a8eee8965a55f171ecbdff6c54bd
BLAKE2b-256 f17a491956f0dd9448ac90e805feb479f67dcb8d7d7de170429690bdf06efc4c

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