Pattern: Pricing Plan

How can the API provider meter API service consumption and charge for it?


The final version of this pattern is featured in our book Patterns for API Design: Simplifying Integration with Loosely Coupled Message Exchanges.

Pattern: Pricing Plan

a.k.a. Pricing Plan, Metering and Billing, Accounting

Context

An API is an asset of the organizations or individuals that have built it. From the viewpoint of commercial organizations, this means that it has both monetary and immaterial value. The development and operations of this asset has to be funded somehow. The API clients can be charged for API usage, but the API provider can also sell advertisements or find other means of raising funds.

Problem

How can the API provider meter API service consumption and charge for it?

Forces

When metering and billing, the following concerns are hard to resolve in a way that is acceptable both for API clients and providers:

  • Economic aspects
  • Accuracy
  • Meter granularity
  • Security

Pattern forces are explained in depth in the book.

Solution

Assign a Pricing Plan for the API usage to the API Description that is used to bill API customers, advertisers, or other stakeholders accordingly. Define and monitor metrics for measuring API usage, such as API usage statistics per operation.

Sketch

A solution sketch for this pattern from pre-book times is:

Example

Imagine a fictitious provider offering an API to programmatically send and receive e-mails, liberating clients from working with the SMTP and POP/IMAP protocols directly. The provider decided to implement a usage-based Pricing Plan, with a freemium level for low usage and different pricing levels depending on how many emails per month are sent, as can be seen in Table tbl. 1.

Table 1: Example of a usage-based Pricing Plan of a fictitious API provider with different billing levels.
E-Mails per Month (up to) Pricing per Month
100 Free
10’000 $20
100’000 $150
1’000’000 $1000

A competitor of the provider, trying to differentiate itself and wanting to keep the monitoring at a minimum, might instead decide to go with a flat-rate subscription fee of $50 per month that offers unlimited e-mails to clients.

Are you missing implementation hints? Our papers publications provide them (for selected patterns).

Consequences

The resolution of pattern forces and other consequences are discussed in our book.

Known Uses

Pricing Plans are widely used by commercial offerings of all kinds:

  • Business Support Systems (BSS) have been used in telecommunications for a long time; many mature billing and metering solutions exist in this industry. The TM Forum Applications Framework 3.0 covers these and other related business capabilities on a platform-independent level.
  • A dynamic interface to a core banking backend Brandner et al. (2004) allows implementing usage-based pricing per operation type; a banking customer portfolio lookup may have a different price than an account balance check.
  • AWS Lambda implements usage-based pricing with a free-tier of one million requests per month and $0.20 for each further million requests.
  • Amazon S3 is an example of usage-based pricing of storage capacity and operations performed on the storage. It also comes with several pricing tiers and volume discounts.
  • CloudConvert offers both prepaid packages of conversion-minutes and different monthly subscriptions.
  • Amazon EC2 Spot Instances use market-based pricing.

More Information

Related Patterns

A Pricing Plan can use Rate Limits to enforce different billing levels. If used, the Pricing Plan should refer to the Service Level Agreement.

To identify the client making a request, an API Key can be used (or another authentication practice). A Wish List or a Wish Template can help to keep costs low if amount of data transferred is part of the Pricing Plan definition.

API Gateways Richardson (2016) and the systems management patterns in Hohpe and Woolf (2003), especially Wire Tap, can be used to implement metering and can thus also be used as enforcement points. A Wire Tap can be inserted between the source and destination of a message to copy incoming messages to a secondary channel or a Message Store that is used to count the requests per client without having to implement this at the API endpoint.

References

Brandner, Michael, Michael Craes, Frank Oellermann, and Olaf Zimmermann. 2004. “Web Services-Oriented Architecture in Production in the Finance Industry.” Informatik-Spektrum 27 (2): 136–45. https://doi.org/10.1007/s00287-004-0380-2.
Fehling, Christoph, Frank Leymann, Ralph Retter, Walter Schupeck, and Peter Arbitter. 2014. Cloud Computing Patterns: Fundamentals to Design, Build, and Manage Cloud Applications. Springer.
Hohpe, Gregor, and Bobby Woolf. 2003. Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions. Addison-Wesley.
Richardson, Chris. 2016. “Microservice Architecture.” http://microservices.io.
Zimmermann, Olaf. 2015. “Architectural Refactoring: A Task-Centric View on Software Evolution.” IEEE Software 32 (2): 26–29. https://doi.org/10.1109/MS.2015.37.