---
title: "How to Calculate MRR from the Stripe API (Code + Formula)"
description: "Calculate MRR from the Stripe API in TypeScript: paginate active, trialing, and past_due subscriptions, then apply quantity, intervals, and coupons."
canonical: https://datalighthouse.dev/guides/calculate-mrr-from-stripe-api
last-updated: 2026-11-11
---

# How to Calculate MRR from the Stripe API (Code + Formula)
Calculate MRR from the Stripe API in TypeScript: paginate active, trialing, and past_due subscriptions, then apply quantity, intervals, and coupons.
### 1. List active, trialing, and past_due subscriptions

Call subscriptions.list once per status with limit 100. Follow auto-pagination with autoPagingToArray until has_more is false. Omitting status returns every subscription that has not been canceled, including incomplete, unpaid, and paused. Do not stop after the first page.

### 2. Load every item and expand coupons

Read each subscription item's price and quantity. If items.has_more is true, list subscription items for that subscription. Expand discounts so coupon percent_off, amount_off, currency, and duration are objects. An unexpanded discount id does not change MRR. Stripe expand stops at four levels, so expand item coupons on the subscription item list.

### 3. Exclude trials and choose past_due and scheduled cancellations

Count status active. Leave trialing out. past_due stays out unless you opt in. cancel_at_period_end does not change status to canceled until the period ends, so those subscriptions still count unless you omit them on purpose. incomplete, unpaid, paused, and canceled are not part of this list.

### 4. Normalize quantity, interval, and discounts to one month

Monthly amount is unit_amount times quantity, divided by the currency minor-unit factor, then by interval_count. A year divides by 12 times interval_count. A week multiplies by 52/12. A day multiplies by 365/12. Item percent-off and amount-off coupons apply before subscription coupons. Duration once does not change MRR. Repeating coupons apply while end is null or still in the future. Forever coupons always apply.

### 5. Keep currencies separate and skip metered prices

The normalizer locks the first priced item's currency and skips later items in another currency. It does not convert currencies. usage_type metered and billing_scheme tiered are skipped, because a per-unit rate or a null unit_amount is not a flat monthly fee. Sum usage from invoice lines or meter events in a separate report.

## FAQ
### Does the Stripe API return MRR?

No. The Subscription, Subscription Item, and Price objects do not include an MRR field. You compute it from price.unit_amount, quantity, recurring.interval, and recurring.interval_count, after you paginate the subscriptions you decided to count.

### Which Stripe subscription statuses should I list for MRR?

List active, trialing, and past_due so the excluded rows are visible. The function on this page counts status active only. Trialing is excluded. past_due is excluded unless includePastDue is true. incomplete, incomplete_expired, unpaid, paused, and canceled are not requested. Omitting the status filter returns every subscription that has not been canceled, which is a wider set.

### Does cancel_at_period_end remove a subscription from MRR?

Not by itself. Stripe keeps status active until the current period ends, then moves the subscription to canceled. The function includes those subscriptions unless excludeCancelAtPeriodEnd is true. A future cancel_at with cancel_at_period_end set to false still counts.

### How do once, repeating, and forever coupons affect MRR?

A forever coupon applies to the run-rate. A once coupon reduces one invoice and does not change MRR. A repeating coupon applies while the discount end timestamp is null or still in the future. percent_off scales the monthly amount. amount_off is a minor-unit discount for that billing period and is normalized with the same interval factor. Item discounts apply before subscription discounts. An unexpanded discount id is ignored.

### Why are metered and mixed-currency prices left out?

A metered price bills recorded usage, and a tiered price has no single unit_amount. Summing the per-unit rate would invent a flat fee. The normalizer skips both and reports them as skipped items. It also locks the first priced currency and skips later items in another currency instead of converting them. Report each currency on its own.

### Where can I see this MRR calculation in a dashboard?

Data Lighthouse is a self-hosted Next.js template. The overview normalizes active Stripe subscriptions to one month with the same interval factors, includes quantity, follows auto-pagination, and leaves trialing subscriptions out. The license is $59 once. The buyer page is https://datalighthouse.dev/nextjs-stripe-analytics-dashboard and the sample dashboard is https://datalighthouse.dev/demo. The demo uses sample data and does not call Stripe. The SaaS metrics calculator at https://datalighthouse.dev/tools/saas-metrics-calculator runs the same monthly normalization in the browser. The Stripe MRR CSV calculator at https://datalighthouse.dev/tools/stripe-mrr-csv-calculator reads a subscriptions CSV in the browser and does not upload it.


## Sources
- [Stripe API: list subscriptions](https://docs.stripe.com/api/subscriptions/list)
- [Stripe API: Subscription object](https://docs.stripe.com/api/subscriptions/object)
- [Stripe API: Subscription Item object](https://docs.stripe.com/api/subscription_items/object)
- [Stripe API: Price object](https://docs.stripe.com/api/prices/object)
- [Stripe API: Coupon object](https://docs.stripe.com/api/coupons/object)
- [Stripe API: Discount object](https://docs.stripe.com/api/discounts/object)
- [Stripe API: pagination](https://docs.stripe.com/api/pagination)
- [Stripe: expanding responses](https://docs.stripe.com/expand)
- [Stripe: zero-decimal currencies](https://docs.stripe.com/currencies#zero-decimal)
- [Stripe: subscription statuses](https://docs.stripe.com/billing/subscriptions/overview)
- [Stripe: subscription quantities](https://docs.stripe.com/billing/subscriptions/quantities)
