Skip to content
Market Monolith

Python and Market Monolith

Use Python's standard library for an authentication-only example.

Instructions published. Connection not available.

On this page

Use Python's standard library for the first authentication check. No Market Monolith Python package or connected integration is published in this release.

Server-side example

The standard-library urllib.request documentation describes requests, handlers and timeouts. Run this example only after the authentication release is confirmed and inject the key through your approved secret manager.

import json
import os
import urllib.error
import urllib.request

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

key = os.environ.get("MARKET_MONOLITH_API_KEY")
if not key:
    raise RuntimeError("A server-side API key is required")

request = urllib.request.Request(
    "https://api.marketmonolith.com/v1/me",
    headers={"X-Market-Monolith-Key": key, "Accept": "application/json"},
)
opener = urllib.request.build_opener(NoRedirect())
try:
    with opener.open(request, timeout=10) as response:
        identity = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(
        "Authentication check returned HTTP " + str(error.code)
    ) from None

print({
    "accountRef": identity.get("accountRef"),
    "applicationRef": identity.get("applicationRef"),
    "businessAccess": identity.get("businessAccess"),
    "billable": identity.get("billable"),
})

Limits of the result

The code declines redirects and does not retry. A network timeout is not a reason to reveal the key or dump request headers.

Compare the returned references with your console. Authentication is free and does not enable a business API, reserve credits or connect a Python workflow.

Support boundary

Your Python runtime supplies the HTTP client. Market Monolith owns the documented authentication contract, not a published SDK lifecycle. Use API-key security before sharing example code.

View as Markdown Documentation index for agents Reviewed 2026-08-28 Support: Market Monolith guide; Python client