This guide is for developers who need to install the library, configure the client, and use its sync or async APIs in their own code.
Install the package with pip or uv:
pip install mpt-api-client
uv add mpt-api-client- Python 3.12+
- Access to an MPT API base URL
- An MPT API token
The client requires a base URL and an authentication provider.
Environment variables:
| Variable | Required | Description |
|---|---|---|
MPT_API_BASE_URL |
yes | SoftwareONE Marketplace API URL |
The base URL can be read from the environment; the authentication provider is always passed explicitly.
Example .env snippet:
MPT_API_BASE_URL=<YOUR_MPT_API_BASE_URL>Authentication is provided through an Authentication provider passed to the client. Two
implementations are available:
BearerTokenAuthentication— a single, long-lived token.ExtensionFrameworkAuthentication— a short-lived installation or account-scoped token fetched from an extension secret viaPOST /installations/-/token. It refreshes proactively once the token nears its JWTexp(default leeway 60s) and reactively on401. Passaccount_idto request a token scoped to a specific account (?account.id=<id>); use one provider instance per account scope.
With a long-lived bearer token:
from mpt_api_client import MPTClient, BearerTokenAuthentication
client = MPTClient.from_config(
authentication=BearerTokenAuthentication("<token>"),
base_url="https://api.s1.show/public",
)With the extension framework (short-lived installation tokens):
from mpt_api_client import MPTClient, ExtensionFrameworkAuthentication
client = MPTClient.from_config(
authentication=ExtensionFrameworkAuthentication(secret="<extension-secret>"),
base_url="https://api.s1.show/public",
)For an account-scoped token, pass account_id:
client = MPTClient.from_config(
authentication=ExtensionFrameworkAuthentication(
secret="<extension-secret>",
account_id="<account-id>",
),
base_url="https://api.s1.show/public",
)from_config also accepts a timeout argument (HTTP request timeout in seconds, default 60.0).
Read a single resource:
from mpt_api_client import MPTClient, BearerTokenAuthentication
client = MPTClient.from_config(
authentication=BearerTokenAuthentication("<token>"),
base_url="https://api.s1.show/public",
)
product = client.catalog.products.get("PRD-123-456")
print(product.name)Iterate through a collection:
from mpt_api_client import MPTClient, BearerTokenAuthentication
client = MPTClient.from_config(
authentication=BearerTokenAuthentication("<token>"),
base_url="https://api.s1.show/public",
)
for invoice in client.billing.invoices.iterate():
print(invoice.id)import asyncio
from mpt_api_client import AsyncMPTClient, BearerTokenAuthentication
async def main():
client = AsyncMPTClient.from_config(
authentication=BearerTokenAuthentication("<token>"),
base_url="https://api.s1.show/public",
)
product = await client.catalog.products.get("PRD-123-456")
print(product.name)
async for item in client.catalog.products.iterate():
print(item.id, item.name)
asyncio.run(main())The client exposes resource groups such as:
client.accountsclient.auditclient.billingclient.catalogclient.commerceclient.exchangeclient.helpdeskclient.integrationclient.notificationsclient.programclient.spotlight
See architecture.md for the repository structure and the MPT OpenAPI spec for the upstream endpoint contract.
Use filter(), order_by(), and select() on queryable resources.
The full RQL syntax and builder usage are documented in rql.md. Treat that file as the source of truth for query composition.
Typical example:
from mpt_api_client import MPTClient, BearerTokenAuthentication, RQLQuery
client = MPTClient.from_config(
authentication=BearerTokenAuthentication("<token>"),
base_url="https://api.s1.show/public",
)
target_ids = RQLQuery("id").in_(["PRD-123-456", "PRD-789-012"])
active = RQLQuery(status="active")
vendor = RQLQuery("vendor.name").eq("Microsoft")
query = target_ids & active & vendor
for product in (
client.catalog.products
.filter(query)
.order_by("-audit.updated.at")
.select("id", "name")
.iterate()
):
print(product.id, product.name)- testing.md: validation and test command behavior
- rql.md: RQL builder guide
- architecture.md: repository structure and abstractions
- local-development.md: repository-local Docker workflow for contributors