Skip to main content
The Stream Blueprint sends a usage event to Dodo Payments with the number of bytes a customer consumed from a stream. A Sum meter over bytes adds up each customer’s bandwidth, so you can bill for it. The blueprint ships in the @dodopayments/ingestion-blueprints npm package as trackStreamBytes().

Use Cases

The Stream Blueprint fits these scenarios:

Video Platforms

Bill customers for video bandwidth consumption and streaming quality.

Music Streaming

Track audio streaming usage per user for subscription tiers.

Live Events

Monitor live stream consumption and charge for bandwidth usage.

Real-Time Data

Track real-time data transfer for IoT and telemetry applications.
Use it for video and audio streaming platforms, live streaming services, and real-time data applications.

Quick Start

To track streaming usage, install the package, create a meter, and send the bytes each customer consumes.
1

Install the SDK

Install the Dodo Payments Ingestion Blueprints package:
2

Get Your API Keys

Create a Dodo Payments API key under Developer → API Keys in the Dodo Payments dashboard, and store it in the DODO_PAYMENTS_API_KEY environment variable. Use a test mode key while you build. A test mode key works only with test_mode.
3

Create a Meter

In the Dodo Payments dashboard, go to Products → Meters and click Create Meter. Set these fields:
  • Meter Name: a descriptive name, such as Stream Bandwidth.
  • Event Name: stream_consumption, or a name you choose. It must match eventName in your code exactly (case-sensitive).
  • Aggregation Type: Sum, to add up the bytes streamed.
  • Over Property: bytes, to bill by bandwidth usage.
  • Measurement Unit: the unit shown on invoices, such as bytes.
4

Track Stream Usage

Call trackStreamBytes() with the customer and the number of bytes consumed:

Configuration

Ingestion Configuration

Pass these options to new Ingestion():
string
required
Your Dodo Payments API key from the dashboard.
string
Environment mode: test_mode or live_mode. Defaults to test_mode. The Dodo Payments SDKs default to live_mode instead, so set live_mode explicitly in production.
string
required
Event name that matches your meter’s Event Name (case-sensitive).

Track Stream Bytes Options

Pass these options to trackStreamBytes():
string
required
The Dodo Payments customer ID to bill for the stream, for example cus_123.
number
Number of bytes consumed in the stream. Required for bandwidth-based billing. If you omit it, the event has no bytes value, but it still counts toward a Count meter.
object
Optional metadata about the stream, such as stream type, quality, or session ID. Each value must be a string, number, or boolean.

Best Practices

Track by Chunk: For long streams, track consumption in chunks rather than waiting for the entire stream to complete.
Each call to trackStreamBytes() sends a separate event, and a Sum meter adds the chunks together.
Accurate Byte Counting: If you bill for total bandwidth, include all overhead, such as headers and protocol overhead, in your byte counts.
Last modified on September 26, 2026