Skip to main content

SDK Usage

This guide shows how to build on top of mpt-extension-sdk.

Install The SDK

Install the package in a consumer project:

pip install mpt-extension-sdk
uv add mpt-extension-sdk

Create An Extension

Start with the Extension primitive. It gives you an event registry and an API surface.

from mpt_extension_sdk.core.extension import Extension

ext = Extension()


@ext.events.listener("orders")
def process_order(client, event):
    """Process order events."""

Add A Validation Endpoint

Use the built-in Ninja API when your extension needs HTTP endpoints.

from mpt_extension_sdk.core.extension import Extension
from mpt_extension_sdk.core.security import JWTAuth

ext = Extension()


def jwt_secret_callback(client, claims):
    """Return the webhook secret used for JWT validation."""
    return "your-webhook-secret"


@ext.api.post("/v1/orders/validate", auth=JWTAuth(jwt_secret_callback))
def process_order_validation(request, order):
    """Validate an incoming order."""
    return {"status": "accepted"}

Build A Processing Pipeline

Use Pipeline for multi-step processing flows.

from mpt_extension_sdk.flows.pipeline import Pipeline


class ValidateOrderStep:
    def process(self, client, context) -> None:
        """Validate the order payload."""


class ProcessOrderStep:
    def process(self, client, context) -> None:
        """Run the main order logic."""


pipeline = Pipeline(
    ValidateOrderStep(),
    ProcessOrderStep(),
)

Run An Extension

Use the swoext CLI when running an extension built on top of the SDK:

swoext run
swoext run api --debug --reload
swoext run consumer
swoext django <command>
swoext shell

Configure The Runtime

The SDK commonly relies on:

  • MPT_API_BASE_URL
  • MPT_API_TOKEN
  • MPT_PRODUCTS_IDS
  • EXT_WEBHOOKS_SECRETS

Example configuration:

EXT_WEBHOOKS_SECRETS={"PRD-1111-1111":"<webhook-secret-for-product>"}
MPT_API_BASE_URL=https://api.s1.show
MPT_API_TOKEN=<your-api-token>
MPT_PRODUCTS_IDS=PRD-1111-1111
MPT_PORTAL_BASE_URL=https://portal.s1.show

Use MPT_API_BASE_URL without /v1 or /public/v1. See configuration.md for the environment-variable reference and migrations.md for the compatibility note behind that rule.

What The SDK Provides

  • an Extension primitive with event listener registration and a Django Ninja API surface
  • runtime wiring for the swoext CLI and packaged Django app configuration
  • reusable helpers for Marketplace HTTP, Key Vault, Airtable, telemetry, and RQL concerns
  • pipeline primitives for multi-step processing flows

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpt_extension_sdk-5.22.1.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpt_extension_sdk-5.22.1-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file mpt_extension_sdk-5.22.1.tar.gz.

File metadata

  • Download URL: mpt_extension_sdk-5.22.1.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.22

File hashes

Hashes for mpt_extension_sdk-5.22.1.tar.gz
Algorithm Hash digest
SHA256 b77ad1f29a88968fecaab0b0ddbbc878d48cca4743c7b8607d0e3c7c2c9a95e7
MD5 c9ba567cfcb8d283faf317c531770f69
BLAKE2b-256 b121650935e6c1af62fb50fb9794be1e87902d4822460fbad6156802c205d003

See more details on using hashes here.

File details

Details for the file mpt_extension_sdk-5.22.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mpt_extension_sdk-5.22.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b2868881293e72726d2c00a0ff108ec6b949b3231d912f83ab1a214abdf878e
MD5 b26bb9b7fbe90e9c3e51dc5af9b138b3
BLAKE2b-256 8882e3ddb291238ef11b251e159d8c4cf58e418adc1e0a7140f28c70165170e6

See more details on using hashes here.

Release history Release notifications | RSS feed

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page