Skip to main content

Metering Concepts

The EMD Digital Metering API enables you to track & limit usage of specific resources via transactions.

Quickstart

Our node SDK has examples to get you started quickly, please see the npm package.

Concepts

Keys

Keys can be anything that has access to resources. This could be a single user of a webapp, or any group whose usage should be considered as a whole.

Keys can only be created/edited by admins, and must be initialized (with a list of resources, and optionally quantity/temporal limits for each resource) before usage can be tracked.

Keys also have a whitelist of audiences who are allowed to record usage via transactions. When creating transactions on a key, access tokens whose aud hasn't been whitelisted for a specific key will receive an Unauthorized error.

Keys can be reset, returning the current usage which should be recorded by your service / payment backend.

Resources

Resources are the units for which you wish to track & limit usage. For example, a user might have only have access to 10 free articles per month on a media platform - you can model this by adding an "articles" resource to a user's key, then setting a limit of 10 and a access expiration date, both of which can be reset on a monthly timer.

Transactions

Transactions record usage amounts for a specific resource on a key. When created, transactions are in a PENDING state, which can be transitioned to CONFIRMED or CANCELED after backend logic completes. Optionally, you can set an expiration time in seconds (default is an hour), after which the transaction will be EXPIRED. Both pending and confirmed usage can be viewed when describing the key.