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.1.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.1-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: penta-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6e418053082317e855a50640d77d04ec337ff62010e35204a14ceab5fdc235ef
MD5 dfcfbe88bfea9b6516c8e3e766c28951
BLAKE2b-256 a5c6e469f5817e7167d18bbb06e0857aea008b4abfa116c0521e27fe1b9236be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: penta-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d250e332b1ef87a99ade131461d87cb8438369a21f88083e4ec63821c32bee39
MD5 0aa7fd71de0ba0a11d8097bfa59ab9b4
BLAKE2b-256 0ff2b38c42d8b254af93f0c780b436c560920cb82eedd779a2e0019faea3932c

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