Skip to content

maykinmedia/zgw-consumers

Repository files navigation

Version:0.35.1
Source:https://github.com/maykinmedia/zgw-consumers
Keywords:OpenAPI, Zaakgericht Werken, Common Ground, NLX

Run CI Coverage status Code linting Documentation Status

python-versions django-versions pypi-version

Manage your external API's to consume.

  • Store services with their configuration in the database
  • Built in ape-pie API client adapter
  • NLX support
  • Declare data/domain objects as modern Python dataclasses
  • Python 3.10 or newer
  • Django 4.2 or newer
  1. Install from PyPI
pip install zgw-consumers
  1. Add zgw_consumers and simple_certmanager to the INSTALLED_APPS setting.

In the Django admin, you can create Service instances to define your external APIs.

Client

To get a client for a given resource, you can use:

from zgw_consumers.client import build_client
from zgw_consumers.models import Service

my_service = Service.objects.get(api_root="https://api.example.com/")
client = build_client(my_service)

with client:
    # The preferred way to use the client is within a context manager
    client.get("relative/url")

The resulting client will have certificate and authentication automatically configured from the database configuration.