Skip to main content
The margin client is available as nozle.margin. All methods accept optional query params such as from and to date strings. Python reserves from as a keyword, so pass date filters with dictionary expansion when you need the exact query parameter name:
summary = nozle.margin.summary(**{"from": "2024-01-01", "to": "2024-01-31"})

Summary

summary = nozle.margin.summary()

By Customer

by_customer = nozle.margin.by_customer(**{"from": "2024-01-01", "to": "2024-01-31"})

By Metric

by_metric = nozle.margin.by_metric()

By Plan

by_plan = nozle.margin.by_plan()

By Model

by_model = nozle.margin.by_model()

Trend

trend = nozle.margin.trend(
    granularity="day",  # "hour" | "day" | "week" | "month"
    **{"from": "2024-01-01", "to": "2024-01-31"},
)

Parameters

Margin query params:
  • from (string, optional) — Start date (ISO 8601)
  • to (string, optional) — End date (ISO 8601)
trend() only:
  • granularity ("hour" | "day" | "week" | "month", default: "day")
All margin endpoints require a secret key (sk_). These are the same endpoints exposed at GET /api/v1/margin/* on the Nozle API.