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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mpt_extension_sdk-5.22.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-5.22.0.tar.gz
Algorithm Hash digest
SHA256 2cbf66f323df025105653c303d6d0caa34476e8f2bb4b0bb2afcb3cb73c21e3e
MD5 e992f5569124e06009e95a7e4a9f4de2
BLAKE2b-256 333ad07aafc285ef12642e993d3ea44675b3fbe643e47cb32a02def15c0778cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mpt_extension_sdk-5.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4c94e6dbb9e2c14a29ccd511c94c9dc3fa7ed3f34600c26c007b47517337a22
MD5 83cf67d7642159df25e8b91a038f07fc
BLAKE2b-256 c50d4409cb7cb13a72a4c8909922335bb3f950ae10c112de331bb0adb289824e

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