Bookmark this page

Configuring Pricing Rules for API Consumption

Objectives

After completing this section, you should be able to configure pricing rules for APIs.

Describing Pricing

Along with exposing your APIs to the public, you might want to charge your consumers for using your APIs. By using Red Hat 3scale API Management you can set price rates for the requests at the product level.

For example, if you have a product called example with two paths, /test and /test1, you might want to charge your consumers for using one or both paths.

In 3scale API Management, pricing rates are linked with application plans. When you create an application plan, you can choose fixed and variable charges for your APIs. Then, you link an application plan with an application, and your consumers use the application's user key to make requests.

Describing Fixed Costs

The fixed costs are applied regardless of the number of requests that the product receives.

You can set a setup fee, which is a one-time charge applied upon subscription to the service. It is only charged the first month and it is not applied when an application moves to another application plan.

You can also set a cost per month fee, which is a fixed charge applied monthly, regardless of the number of requests. If the subscription happens in the middle of the month, then the fee is prorated.

To access the fixed costs, navigate to the product page of the product that you want to use. Then, click ApplicationsApplication Plans and choose the application plan that you want to modify.

In the form you can see two fields: Setup fee and Cost per month.

Figure 7.4: Fixed cost fields from a sample product

Describing Variable Costs

Variable costs are costs that depend on the number of requests that every product receives. You can set variable costs at the request level by using pricing rules.

You create pricing rules for a metric or a method, and you specify the cost of every request linked with the metric or method.

For example, consider that you have a method mapped to the /test path. You create a pricing rule for the method with a cost of 1 USD per request. Therefore, every request to the /test path costs 1 USD.

To create a pricing rule, select an application plan first. Then, in the Metrics, Methods, Limits & Pricing Rules section, click Pricing (X).

Figure 7.5: Pricing rules from a sample product

You set the pricing for a range of requests. The From field sets the lower side of the range, and the To field sets the higher side of the range. The Cost per request field sets the price of every request in the range.

For example, consider two pricing rules as the following:

From = 1
To = 124
Cost per request = 0.5 USD
From = 125
To = 1000
Cost per request = 0.2 USD

In the previous example, from the first to the 124th request, every request is charged at 0.5 USD. Then, from the 125th to the 1000th request, every request is charged at 0.2 USD.

Note

Keep in mind that, because the default Hits metric captures all paths (/), the pricing rules linked to the Hits metrics are applied to all paths.

Revision: do240-2.11-40390f6