Easily Monetize Your APIs with Moesif Plus Chargebee

It’s always great to build something that makes money. The most successful businesses often find the easiest and most efficient ways to make money, while keeping costs and support to a minimum. After all, the best businesses and products are simply the ones that know how to build revenue. Many companies now look to monetizing their APIs as part of their overall monetization strategy.

API monetization isn’t always easy though. It generally takes a lot of integrations, a fair amount of code and customization, and can also lead to a large support burden. This is especially true when billing issues arise. In short, there are challenges both during implementation, and once the billing system is up and running.

What if a simpler approach was possible? At Moesif, we recently introduced a feature for Billing Meters. This is a way to use the data coming into Moesif to monitor usage for a user, send this data to a billing provider, and have the users be presented with accurate bills, all with a fraction of the work required to implement a custom solution.

To illustrate how it works, let’s assume we have an API that we would like to charge customers to use. As an example, let’s pretend that we have created a new credit score API that companies can use to bring consumers’ credit ratings back to their app. Our API will be /getCreditScore, and users will be charged for each query/call they send to the endpoint. Our API monetization model will be pretty simple, we will charge $0.10 for every call to our /getCreditScore endpoint.

Chargebee will be the billing provider that we will use to invoice and charge customers for their usage. Chargebee is simple to use and will allow us to easily set up plans and pricing to adhere to the pricing scheme above.

We will now use Moesif to tally up the usage for the endpoint and send the usage metrics to Chargebee. Chargebee can then use these metrics to bill the customer accordingly, based on the tier that their metrics coincide with, and collect payment.

Integrate your app and APIs with Moesif

In order to use the Billing Meters feature in Moesif, you need to have your APIs integrated with Moesif. This is because Moesif will use the metrics stored within it and then feed Chargebee the info it needs. Once your APIs are integrated with Moesif, you can also use other features which pair well with our Billing Meters feature, including behavioral emails, governance rules, and alerts.

If you are not currently using Moesif to monitor your APIs, integration can be done in a few different ways. If you are using an API gateway or API management platform, you can use one of our many plugins which allow you to quickly feed analytics to Moesif. If you are not using a third-party gateway or management platform, or want to do it at the API code level, you can use one of our SDKs. A Moesif SDK will allow you to easily integrate Moesif with your Node, Python, or Java APIs (plus many, many more languages and frameworks) directly from your code. Either way is easy and simple to support.

Another Moesif feature that you need to deploy in order to make billing work correctly, is to implement user and company tracking. Generally, this can be set up in a few simple steps. We need this feature enabled so that usage data in Moesif can be tied to specific users and companies. This is how Chargebee will map usage to a customer within Chargebee, so they can be billed accordingly.

Once you have integrated with Moesif, and have user and customer tracking enabled, your next step would be to actually create your plans in Chargebee, so they can be used in Moesif.

Create plans and prices in Chargebee

After creating a Chargebee account and logging in, you can begin to create your plans. For our purposes, we need to create a plan which includes an price that uses standard pricing.

You’ll need to create a plan in Chargebee which that is metered. the price should be set to a monthly billing interval so that the usage is totalled up at the end of the month. The unit price would also need to be set to $0.10.

Setting the plan up, for example, will look like this:

example

The monthly pricing details will look like this:

example

Now, at the end of the month, when Chargebee creates the invoice, it will add up the total usage and bill the customer accordingly. Of course, at this point, we only have the plans defined, but no one will be charged since we don’t yet have any usage data being sent to Chargebee.

Learn More About Moesif Integrate Metered Billing Easily 14 day free trial. No credit card required. Learn More

Integrate Chargebee with Moesif

We still need to actually get the data from Moesif over to Chargebee, and vice versa. There are two mechanisms that are used for this: a webhook and the Chargebee API. Each has a distinct part in facilitating the data sharing between the platforms.

By adding the webhook into Chargebee, subscription updates can be sent back to Moesif. By using the Chargebee API, Moesif can send usage details to Chargebee and can also retrieve details about available plans and prices in Chargebee. These two points of contact are all that’s needed for the Chargebee and Moesif integration. Thankfully, Moesif walks you through this when you set up Chargebee as a billing provider and provides all the needed details. For the specifics, you can also check out our docs on the Chargebee integration.

Set your billing parameters

Once you’ve integrated Chargebee in Moesif, you can set up your billing meter. For our example, it will be very simple. What we will do is send usage metrics to Chargebee whenever an API call to /getCreditScore returns a “200 OK” response. This means we will only bill for successful calls and won’t accidentally charge for calls where an error was experienced.

example

Once we create the billing meter, every hour the usage for each customer will be sent to Chargebee. At the end of the month, Chargebee will create an invoice based on our pricing structure and bill the user.

You can also use Moesif to automatically send behavioral emails for every successful call, or even if they are about to cross into the next discount tier. You could also use Moesif’s Governance Rules to block users with overdue invoices from accessing the API until their invoice is settled.

Try it out for yourself

As you can see, you are just a few steps away from robust API monetization that is simple to implement and support. By using Moesif and Chargebee together you’ll be able to charge customers for usage in a matter of minutes, manage subscriptions, and can even use other Moesif features to create the ultimate customer experience. Our billing setup is so simple that it can even be done without having any developer skills.

The Billing Meters feature is available for all Moesif users. Sign up for Moesif today to instantly access our Billing Meters feature to begin billing for your customers’ API usage. If you’re already using Moesif, click on Billing Meters in the left-side navigation menu and take a look at our docs to show the exact steps to get you to monetize your APIs.

Learn More About Moesif Easily Monetize Your APIs 14 day free trial. No credit card required. Learn More
Monetize in Minutes with Chargebee and Moesif Monetize in Minutes with Chargebee and Moesif

Monetize in Minutes with Chargebee and Moesif

Learn More