API

Apps

Meta information about the Integreat CMS API app

class integreat_cms.api.apps.ApiConfig(app_name, app_module)[source]

Bases: AppConfig

Configuration parameters for the API app

name: Final[str] = 'integreat_cms.api'[source]

Full Python path to the application

verbose_name: Final[Promise] = 'API'[source]

Human-readable name for the application

Decorators

This module includes functions that are used as decorators in the API endpoints.

integreat_cms.api.decorators.feedback_handler(func: Callable) Callable[source]

Decorator definition for feedback API functions and methods

Parameters:

func (Callable) – decorated function

Returns:

The decorated feedback view function

Return type:

Callable

integreat_cms.api.decorators.json_response(function: Callable) Callable[source]

This decorator can be used to catch Http404 exceptions and convert them to a JsonResponse. Without this decorator, the exceptions would be converted to HttpResponse.

Parameters:

function (Callable) – The view function which should always return JSON

Returns:

The decorated function

Return type:

Callable

integreat_cms.api.decorators.matomo_tracking(func: Callable) Callable[source]

This decorator is supposed to be applied to API content endpoints. It will track the request in Matomo. The request to the Matomo API is executed asynchronously in its own thread to not block the Integreat CMS API request.

Only the URL and the User Agent will be sent to Matomo.

Parameters:

func (Callable) – decorated function

Returns:

The decorated feedback view function

Return type:

Callable

Urls

Expansion of API-Endpoints for the CMS

integreat_cms.api.urls.app_name: Final = 'api'[source]

The namespace for this URL config (see django.urls.ResolverMatch.app_name)

integreat_cms.api.urls.urlpatterns: list[URLPattern] = [<URLResolver <URLPattern list> (None:None) 'api/v3/regions/'>, <URLResolver <URLPattern list> (None:None) 'wp-json/extensions/v3/sites/'>, <URLResolver <URLPattern list> (None:None) 'api/v3/<slug:region_slug>/'>, <URLResolver <URLPattern list> (None:None) '<slug:region_slug>/'>][source]

The url patterns of this module (see URL dispatcher)

[
    <URLResolver <URLPattern list> (None:None) 'api/v3/regions/'>,
    <URLResolver <URLPattern list> (None:None) 'wp-json/extensions/v3/sites/'>,
    <URLResolver <URLPattern list> (None:None) 'api/v3/<slug:region_slug>/'>,
    <URLResolver <URLPattern list> (None:None) '<slug:region_slug>/'>,
]