How to Show the Business Value of Your APIs with Embedded Metrics

When you’re providing APIs to your customers, you want to ensure they are getting value from them. At the same time, the best APIs are designed to be fully automated without requiring human intervention. This can leave your customers in the dark on whether your API is even being used by the organization and if you’re meeting any SLA obligations in your enterprise contracts.

Types of metrics to surface

Most API first companies have some sort of developer portal for customers to log into, manage API keys, and customize features. This area is a great way to also expose key metrics to your customers demonstrating how much value they are getting from your API. This can be as simple as a counter showing number of API transactions made within a billing period or provide additional metrics around what those transactions are. Each customer has different metrics they want to look at. Developers will want to look at access logs where as product and engineering leadership are more interested in usage and performance metrics. Finally, the finance department may need to look at billing usage for capacity and financial planning.

Providing API Logs

A quick and easy way to demonstrate your empathy towards your developers is by providing API logs. Engineers are now integrating countless APIs to ship their applications. They don’t have time to understand every response or error code that your API creates. Yet, having detailed and structured logs is super helpful for debugging integration issues. Instead of relying on your customers to instrument your integration, you can easily provide API logs directly in your developer portal. If you take this approach, ensure your access logs are useful by including the following features:

  • Structured data which enables developers to drill down quickly without slow search
  • Included context beyond request parameters such as client location or API version
  • Advanced filters which enable creating compound queries including body fields
  • Replay functionality in tools like Curl, Swagger UI, and Postman
  • Event Ids that can be shared with developer support

Displaying API usage

While business and engineering leadership may need to inspect the API logs themselves, they are keen on having the right metrics in place to make informed decisions. If they’re sponsoring a new project, they want to ensure they’re getting their money’s worth. Providing metrics on usage of your platform helps demonstrate the value business leaders receive.

Embedded API logs

API calls themselves don’t show value, but they represent some sort of business transactions, whether making a payment or sending a text message to remind an end user that a delivery is present. Because of this, ensure your usage reports can show the historical number of transactions in a given period. Requirements for usage reports include:

  • Ability to see usage by different intervals like hour/day/month
  • Shows number of business transactions, even if your API can handle requests in batch
  • A way to break usage down by user demographics

Displaying Performance Metrics

While some APIs are used by only internal applications, many are integrated within customer-facing apps. If your API has performance or reliability issues, this can impact their end users. This can tarnish their reputation or cause lost revenue. If you have an obligation to meet certain SLAs (Service Level Agreements), show that to your customers. This can provide peace of mind knowing that your APIs are reliable and performant.

Embedded SLA metrics

Providing Billing Dashboards

Most APIs leverage consumption based billing. If you’re providing a payments API, this may be the number of transactions per month or percentage of dollar volume. Whereas if you’re providing a messaging API, you may bill based on the number of messages sent within a billing period. Your customers will want to optimize their usage to maximize the value of your API, which means you should show where their money is being spent. Keep in mind you should have a consistent source of truth for billing, otherwise your support team will be bombarded with requests due to a billing discrepancy.

Outside of billing, you should also show any rate limits or quotas that your customers are bound by. In fact, this can be an easy way to upsell to larger plans by showing how close they are to current limits. Because many business teams are unaware of or don’t log into your developer portal, you should also send out notifications letting your customers know once quotas are breached.

Subscription quota emails

How to get started with embedded charts

With Moesif, you can embed API logs and usage reports in a few minutes. The integration has three parts

  1. Create an embed template within the Moesif UI with the correct view and filters. You should also select your dynamic variable names like user_id or company_id which will be set in the second step
  2. An API on your backend that calls the Moesif management API to get a time-limited workspace URL. This is returned to your frontend
  3. Embed the chart using an iFrame with the generated workspace URL.

A working React app using Moesif embed template is available here.

To embed a chart or API log:

Step 1. Create a new embed template in Moesif

  1. Go to Events from the top menu and select the view you want to embed.
  2. Add any filters and other chart settings that you want applied to the embedded chart.
  3. Click on the Share button at the top right and then select the Embed Template tab.

Creating embedded API logs

  1. Add any dynamic variables such as a User Id or a Company Id.
  2. Click Get Embed Code, You will be presented with the code snippets to add to your application (also shown below).

Step 2. Generates the workspace URL

Create a new endpoint that calls the Moesif API to generate workspace URLs. When you call the Moesif API, set the dynamic variables you added to your template in step 1. In this example, user_id is a dynamic field that needs to be populated with the correct value.

curl -X POST -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' -H 'Content-Type: application/json' -i 'https://api.moesif.com/v1/portal/~/workspaces/{WORKSPACE_ID}/access_token
  -d '{
  "template": {
    "values": {
      "user_id": "1234"
    }
  }
}'

Moesif returns a workspaces URL. This URL can only access the data defined by step 1. In this example, the data is scoped to user id 1234.

{
  access_token: '{WORKSPACE_ACCESS_TOKEN}',
  url: 'https://www.moesif.com/public/{WORKSPACE_ACCESS_TOKEN}/ws/{WORKSPACE_ID}?embed=true
}

Step 3. Add the iFrame

Add an iFrame to your frontend using the workspace URL generated in step 2. A user with the workspace URL can only access the data scoped based on your dynamic variables set in step 2.

<iframe
  id="preview-frame"
  src="https://www.moesif.com/public/{WORKSPACE_ACCESS_TOKEN}/ws/{WORKSPACE_ID}?embed=true"
  name="preview-frame"
  frameborder="0"
  noresize="noresize">
</iframe>

Conclusion

Demonstrating the value your customers get can go a long way to making your customers successful. With Moesif, it’s easy to embed API metrics and logs into your application with just a few lines of code.

Embed API logs and metrics with a few lines of code

Embed API logs and metrics with a few lines of code

Learn More