Skip to main content

feincms3-api

A django-ninja API for reading and writing the content of feincms3 sites: pages and other objects with django-content-editor regions and plugins, django-json-schema-editor data and django-cabinet files. For scripts, importers and agents, next to the Django admin, not instead of it.

Status: alpha. The wire format and the Python API may still change.

The admin is the source of truth: the API finds, validates, saves and permits exactly what the admin does, through the admin's querysets, forms, formsets, save hooks and permissions. A plugin with custom validation, or a project hooking save_formset(), behaves the same through the API without any code for the API.

Setup

pip install feincms3-api
INSTALLED_APPS = [
    ...,
    "feincms3_api",
]

Register what the API exposes; nothing else is. Each model needs a ModelAdmin, that's where the forms, permissions and plugins come from:

# app/content_api.py
from feincms3_api.api import ContentAPI
from feincms3_api.cabinet import FileResource, FolderResource
from feincms3_api.forms import ConfiguredFormResource
from feincms3_api.resources import ObjectResource, PageResource, TreeResource

from app.articles.models import Article
from app.forms.models import Form
from app.pages.models import Page

content_api = ContentAPI()
content_api.register(PageResource(Page))
content_api.register(ObjectResource(Article))
content_api.register(ConfiguredFormResource(Form))  # feincms3-forms
content_api.register(FileResource())  # django-cabinet
content_api.register(FolderResource())

Mount it, either as an API of its own or as a router in an existing NinjaAPI:

# app/urls.py
from app.content_api import content_api

urlpatterns = [
    ...,
    path("api/content/", content_api.as_api().urls),
]

./manage.py migrate creates the tables for tokens and uploads. The interactive docs are at api/content/docs.

Settings

FEINCMS3_API = {
    # Never exposed: fields, or values inside JSON data
    "EXCLUDE_FIELDS": [
        "forms.form.recipient_email",
        "pages.jsonplugin_key_figures.data.internal_note",
    ],
    # What a string is, where its form field and name don't tell
    "KINDS": {"tipps.tipplist.color": "machine"},
    "MAX_BATCH_OPERATIONS": 100,
    "DEFAULT_PAGE_SIZE": 50,
    "MAX_PAGE_SIZE": 200,
    "TOKEN_LIFETIME": timedelta(hours=8),
    "UPLOAD_LIFETIME": timedelta(days=1),
    "UPLOAD_STORAGE": "default",
}

The schema snapshot

./manage.py f3api_schema app.content_api.content_api prints every type with its fields and what kind of value each is, as a superuser sees them. Commit it and compare it in a test, so a new plugin or field becomes visible through the API only after someone looked at the diff.

Using it

Only active staff users can use the API, with their admin permissions. Scripts and agents use tokens: staff users create their own in the admin (the secret is shown once), or ./manage.py f3api_token USERNAME --write prints one. Tokens are read-only unless created for writing, and expire after TOKEN_LIFETIME. ./manage.py f3api_cleanup removes expired tokens and uploads; run it daily.

API=https://example.com/api/content
AUTH="Authorization: Bearer f3api_…"

curl -H "$AUTH" $API/schema/                       # what's there
curl -H "$AUTH" "$API/pages/find/?path=/de/angebot/"
curl -H "$AUTH" "$API/pages/17/?expand=references"  # one page with its content

Writes need the ETag of what was read (If-Match), and fail as a whole with every problem and its path. ?dry_run=true runs a write in a transaction which is rolled back and returns what it would have done:

curl -X PUT -H "$AUTH" -H 'If-Match: "9f2c…"' -H "Content-Type: application/json" \
  "$API/pages/17/content/?dry_run=true" \
  -d '{"content": {"main": [
        {"type": "pages.richtext", "fields": {"text": "<h2>Hello</h2>"}}
      ]}}'

A dry run runs everything but the commit, signal handlers included: anything they do outside the database (sending mail, calling other APIs, writing files) happens in a dry run too.

Files are uploaded first (POST /uploads/, multipart) and then named in a write as {"upload": "<id>"}. Changes appear in the admin's history, marked "(Through the API.)".

Credits

feincms3-api grows out of feincms3-autotranslate, started by Moritz Wettstein and Matthias Kestenholz at Feinheit in October 2026. Its content introspection (which fields hold text, HTML or links, JSON schemas, plugin discovery) is the base of this package.

Metadata

Release files for feincms3-api 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for feincms3-api 0.3.0
File Size Uploaded Provenance Actions
feincms3_api-0.3.0.tar.gz 50.2 kB With provenance Details for feincms3_api-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for feincms3-api 0.3.0
File Interpreter ABI Platform Actions
feincms3_api-0.3.0-py3-none-any.whl Python 3 none any Details for feincms3_api-0.3.0-py3-none-any.whl

Total release size: 113.5 kB

Release files / feincms3_api-0.3.0.tar.gz

Download URL feincms3_api-0.3.0.tar.gz
Size 50.2 kB
Tags Source
SHA-256 checksum
How to use checksums
995a5f270052c4da5fe1c41ae6400d475be8113b44e5d74c3ab1b3d500b5c9ae
BLAKE2b-256 checksum
How to use checksums
17cafe6ff15ebc011099cb46d2839ebc5dc14494a79056e652bceed9f2f6d0ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / feincms3_api-0.3.0-py3-none-any.whl

Download URL feincms3_api-0.3.0-py3-none-any.whl
Size 63.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7074fea95828fd3436c4bf352515f60b352bee10f324ac2103bc09942a5f9f75
BLAKE2b-256 checksum
How to use checksums
d2d312670f4b03f6c28f6aae7c6bb45a1b8aaa3d47ec44f52984ea6801ddc3d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Security for feincms3-api 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.

Select from 2 files

Attestation for feincms3_api-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 Nov 17, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page