# Python and Market Monolith

Availability: Instructions published.
Connection status: Connection not available.

Last reviewed: 2026-08-28.

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](https://docs.python.org/3/library/urllib.request.html) describes requests, handlers and timeouts. Run this example only after the authentication release is confirmed and inject the key through your approved secret manager.

```python
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](/docs/api-keys) before sharing example code.
