hawkapi-admin
Auto-generated admin UI for HawkAPI + hawkapi-sqlalchemy models. Drop your model classes in and get list / detail / create / edit / delete views mounted under /admin — no boilerplate, no React, no JSON-schema duplication.
Install
pip install hawkapi-admin
Quickstart
from hawkapi import HawkAPI
from hawkapi_sqlalchemy import Base, TimestampMixin, init_database
from sqlalchemy.orm import Mapped, mapped_column
from hawkapi_admin import Admin, ModelResource, init_admin
class User(Base, TimestampMixin):
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
email: Mapped[str] = mapped_column(unique=True)
name: Mapped[str] = mapped_column(default="")
app = HawkAPI()
init_database(app, url="postgresql+asyncpg://…/myapp")
admin = init_admin(app, title="My App")
admin.register(User) # simplest form
Visit /admin — you get the index page, /admin/user (list), /admin/user/new (create form), /admin/user/{id} (detail), /admin/user/{id}/edit, and POST /admin/user/{id}/delete. All with sane widgets picked from each column's SQLAlchemy type.
Customizing a resource
from hawkapi_admin import ModelResource
admin.register(ModelResource(
model=User,
label="Account",
label_plural="Accounts",
icon="👤",
list_display=("id", "email", "created_at"),
list_search=("email", "name"),
form_fields=("email", "name"),
readonly_fields=("created_at",),
page_size=25,
can_delete=False,
))
| Option | Default | Effect |
|---|---|---|
name |
lowercased class name | URL slug (/admin/<name>) |
label |
class name | Heading on detail / form |
label_plural |
label + "s" |
Nav label & list-page heading |
icon |
"" |
Prepended to nav label |
list_display |
every column | Columns shown on the list page |
list_search |
() |
Columns searched by ?q=... (LIKE) |
form_fields |
every non-PK column | Columns shown in the form |
readonly_fields |
() |
Columns rendered but not editable |
page_size |
50 |
Rows per list page |
can_create / can_update / can_delete |
True |
Toggles the corresponding routes off |
Widgets
hawkapi-admin picks an input widget per column type, automatically:
bool→ checkboxint/float→<input type="number">date/datetime→ matching native inputString(length > 500)→ textareaEnum→<select>with the declared choices- everything else →
<input type="text">
Authentication
The plugin doesn't ship its own auth — it picks up whatever middleware you already attached. Combine with hawkapi-auth and gate the admin prefix:
from hawkapi_auth import requires_scopes
admin = Admin(title="Admin", url_prefix="/admin")
admin.register(User)
admin.attach(app)
@app.middleware("http")
async def gate_admin(request, call_next):
if request.url.path.startswith("/admin"):
# raises 401/403 if the JWT is missing / lacks the scope
await requires_scopes("admin:read")(request)
return await call_next(request)
Theming
The bundled CSS is roughly 60 lines, prefers system colors (light + dark mode), and lives inline in _base.html — copy that template into your own templates/ directory if you want to restyle. Jinja extends "_base.html" keeps working as long as the same blocks (title, content) are defined.
Development
git clone https://github.com/Hawk-API/hawkapi-admin.git
cd hawkapi-admin
uv sync --extra dev
uv run pytest -q
uv run ruff check . && uv run ruff format --check .
uv run pyright src/
License
MIT.
Metadata
Release files for hawkapi-admin 0.3.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 |
|---|---|---|---|---|
| hawkapi_admin-0.3.0.tar.gz | 44.5 kB | With provenance | Details for hawkapi_admin-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hawkapi_admin-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for hawkapi_admin-0.3.0-py3-none-any.whl |
Total release size: 64.1 kB
Release files / hawkapi_admin-0.3.0.tar.gz
| Download URL | hawkapi_admin-0.3.0.tar.gz |
|---|---|
| Size | 44.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b477165418873541039459bbde9c4bae06b3fba1be96839d14fe5ea86dfe3c8b
|
|
BLAKE2b-256 checksum How to use checksums |
594bae01d4526d8bb4447c4cebb53e4ac3fe6b538a118b5872c8fc452cf701d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logRelease files / hawkapi_admin-0.3.0-py3-none-any.whl
| Download URL | hawkapi_admin-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30055932c5d2575d935b29db2b73fb50f17321f0da3e435f51ae58349694e0b2
|
|
BLAKE2b-256 checksum How to use checksums |
28e9f0271d09d12f2f0c8d4ccd7d014e8e722626d2d804d969c0324787ae1b4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logSecurity for hawkapi-admin 0.3.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hawkapi_admin-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 10, 2026.
Transparency logA 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.