Keyrings - ApiAxle

Keyrings have been around in ApiAxle for a while now but they took a bit of a back seat until we got them working with the statistics system. The release of 1.9.14 brings with it keyring statistics support. Here’s an overview of what it is and how it might be useful:

What’s a keyring?

A keyring is simply a way of grouping keys. Say your API is used by many companies each of which have many users (keys). If you want to bill the company based on their overall usage then keyrings are ideal for you.

Keyrings don’t have a relationship with APIs (though, they might in the future). Instead they only know about the keys themselves, this means that a keyring could contain keys that have access to two different APIs.

How do I create them?

ApiAxle API-wise you would first use the create call. Then use the linkkey command to add a key to it. Once you’ve done that and member keys have been hitting the API you can view the statistics.

The REPL equivalent would be (assuming keys f7964f1 and 1d2f58d9 exist):

axle> keyring "ibm" create
axle> keyring "ibm" linkkey "1d2f58d9"
axle> keyring "ibm" linkkey "f7964f1"

Some usage later…

axle> keyring "ibm" stats

How do keyrings work with the statistics?

When keys are used to make calls to an API the keyrings they are attached to get the same style of aggregated statistics as the APIs and keys.

You can narrow the statistics by key and API with the forkey and forapi query parameters respectively.