API Billing

The best way to generate revenue on Mashape as an API Provider is to establish a clear and clever strategy when it comes to setting up a pricing plan, althought the basic pricing features are self-explanatatory there are some advanced features you should know about.

Table of Contents

  1. Private plans
  2. Custom Quotas

Private Plans

A Private Plan solution is now available to all Mashape API providers. These plans are perfect for providers that want to invite select clients to access their API, but not have the API available to the general developer community on Mashape.

Here’s some examples of why and how you’d use Private Plans:

Discount: Provide discounted access to your API to a subset of developers. Test-Driving: Allow developers to use your API for a very small price, with a limited subset of functionalities or allow developers to test the responsiveness of your API at no cost. Heavy Usage: Some use cases where the usage of your API would be heavy by a developer, provide a better rate per functionality or request.

To create a Private Plan for your API, follow these steps:

  • Within your API, navigate to the Private Plans submenu under the Pricing tab
  • Add a new private plan and name it anything you want
  • Customize your custom plan to suit your needs and send it to a developer of your choice!

Custom Quotas

Even more billing flexibility can be achieved with Custom Quotas.

Flexible quotas

You can create up to four custom quotas, like API Requests, Videos, Messages, etc. Also, you can enable or disable features according to each plan: This relies on allowing specific users access to different endpoints.

Default quota behaviour

By default Mashape increments each quota by one unit on every request, with the exception of response code errors (the famous 500 family.) If your API returns an error code equal to or greater than 500, Mashape won’t increment the usage for that user.

Incrementing quota by endpoint used

By having quotas whose usage is increased only when specific endpoints are being requested, it is possible to associate endpoints and quotas. Every time the user requests that specific endpoint, the associated quota will be increased by ONE unit.

Incrementing quota by more than 1 unit

It is possible to override the default behavior and increment the quotas with an arbitrary number of units by setting a special header in the API response in the following format: X-Mashape-Billing: [Quota]=[Value]

For example, to increment the Messages quota by 10 units, you should add the following header to response: X-Mashape-Billing: Messages=10

You can increment more than one quota as well by seperating the values with a semicolon, like so: X-Mashape-Billing: Messages=10; Images=3; Audio=2