Skip to main content

Extensions SDK for SoftwareONE Marketplace Platform

Project description

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

Project details


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-6.0.0.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-6.0.0-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mpt_extension_sdk-6.0.0.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-6.0.0.tar.gz
Algorithm Hash digest
SHA256 9c4c3e66094e047f425ab9f2a0ac4ef69461713cf647fa5d9726d2dcac8e6d96
MD5 36d62a190a3ced3dd3e27828b47f65bb
BLAKE2b-256 2ab7f4f07bf90793269f6f39d5643d49c7b463f0646737e718d3613d2465de40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpt_extension_sdk-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3194326741b1a2742b5ec994be654dc08fe7c29bac7d096af37f680b3ef2c3b3
MD5 87b1dac242d68e6431206f6c7f3fb79e
BLAKE2b-256 5ad5f989db52fa322251652fba4e3d2fb3f58bd4576af7d61148ca79a7339318

See more details on using hashes here.

Supported by

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