Deployment. Authentication. Pricing. Getting an API up and running is a huge project to take on, but using RapidAPI makes it that much easier.
Today, we’ll talk about how to do the following with AWS and RapidAPI.
This tutorial won’t be going into technical depth on the process of coding the API backend, but rather how to get your API deployed with authentication, adding a pricing plan, and getting developers to use your API.
After this article, your API will be officially open for business!
We’ll be using a suite of free business tools from RapidAPI to get up and running as quickly as possible. RapidAPI lets you add user authentication (API keys) and billing plans onto it without any additional development. RapidAPI works as a proxy. Once a call is made, the proxy verifies a developer’s API key, and makes sure that they have a subscription to your API. Only then does the proxy forward the request to your API.
As long as your API knows that the request came from RapidAPI, you can trust that it is authenticated and paid for.
Using AWS to host your API has the benefit of security groups. Security groups allow you to define what IP addresses are allowed to access your server.
To verify that all incoming API requests come from RapidAPI, create a security group that only allows RapidAPI IP addresses to connect to your server.
To make a new security group by logging into AWS, navigating to your instance, and selecting Security Groups. Name the security group “RapidAPI Whitelist”. Then, add all of the RapidAPI IP addresses under the “Source” field.
Once you’ve created the security group, use this new security group on the instance or loadbalancer that is running your API. This security group will ensure that all incoming API requests are from RapidAPI alone, which also means all incoming API requests have been authenticated.
In order for developers to consume your API through RapidAPI, you’ll need to list it on the marketplace. Listing your API makes it available to 400,000 developers on market.mashape.com and rapidapi.com.
First, you’ll need to log into market.mashape.com to select the option to add an API. When you create a new API on RapidAPI, you have the option to import a Swagger 1.2 file. Swagger is a tool used to describe and document RESTful APIs.
If you don’t have a Swagger file, then you can document your API endpoints manually. Get started by selecting the add endpoint button.
You will see five different fields to define the API.
Side note: In some cases, the user may want the functionality to specify a parameter in the route. In this instance, use curly braces to encapsulate the user-defined parameter. For example, if I enter “/status/{appid}” as a Route, an additional parameter input box will be created for the user to specify the parameter’s value
Query-string parameters are used to add additional parameters that can be sent when an API request is made. Adding them to your documentation allows developers to see which parameters are available for them to use when calling the API. Click the blue button to add query-string parameters.
The fields available for query-string parameters are:
Similar to query-string parameters, you can define custom request headers that will be passed to your API endpoint. Select the “Add Deader” button to add request headers to your API.
The fields available for request headers are the same as query-string parameters. However, the API call sends the request headers in a different way than the query-parameters.
When specifying the method to query the endpoint as a POST, PUT or PATCH method, you should also define a payload. You can add it as a single form value or as a model. We’ll walk through how to do both.
A payload defined as a single form value is the simplest way to pass arguments into the payload. We recommend defining a payload as a form because it allows developers to test the API through RapidAPI more easily than a model payload.
Defining a model payload gives more flexibility, as you can specify a lot of parameters at once (see below):
However, developers will have a tough time changing those parameters during testing. Not being able to change the values will make the testing process much more difficult through RapidAPI. Since developers love to try an API before they subscribe, you’ll want to make your API is as easy as possible to test. .
Now that your API is on the marketplace, you are officially ready for business! Since RapidAPI handles all billing, fraud detection and invoicing, all you need to do is set up your plans. If you aren’t sure the best practices for monetizing APIs, check out our API pricing guide on Nordic APIs. For a more in-depth look at our payouts system, visit our docs.
In the meantime, here’s how to add pricing to your API. Within your API on market.mashape.com, navigate to the “Plans” submenu under the Pricing tab. From there, you can define different pricing plans. RapidAPI offers four general tiers: BASIC, PRO, ULTRA, and MEGA. You can think of the audiences for these four tiers as a hobbyist (BASIC), a startup (PRO), a small company (ULTRA) and an enterprise (MEGA). While every API is different, we do have original benchmark data on how people price APIs.
Within this display, you can customize the subscription tiers by adding daily/monthly API request quotas, pricing, and overages fees.
Most API plans are priced by a daily or monthly quota by number of API requests.
In this example, the API is priced by a monthly quota. If a developer goes over the monthly quota, then they will incur the “$ 0.xx per extra” overage fee for each additional API call.
Sidenote: We highly recommend offering a limited free plan as your BASIC tier for developer testing. Plans with a limited free tier see 3x the subscribers as those without. Ensure that developers stay within the quota by charging an overage fee for additional calls.
In some cases, APIs require a more complex pricing plan. If your API falls into a more complicated category, consider adding custom quotas to your API. Let’s use a file storage API as an example. If I wanted to differentiate between file uploads (more expensive) than file downloads (less expensive), I could use custom quotas for each endpoint. These quotas could also include different overage prices. You’re able to define which endpoints the custom quotas are associated with. Here’s an example of a more customized pricing plan.
Keep in mind that, the more custom quotas that you have, the more likely a developer may become confused about your API’s usage. This confusion can result in fewer subscriptions or more disputed overage fees. When you add a custom quota, be as explicit as possible as to what the item is, how it will be incremented and what the quota counts.
You can read more about pricing plans with RapidAPI in our docs, or email us at support@rapidapi.com to talk more about API pricing and best practices when adding an API to the marketplace.
That’s it! You now have authentication, pricing, and outreach to 400,000 developers handled. Now you can get back to what you really love working on: the code.
If you’re interested in learning more about joining the marketplace, you can learn more at https://rapidapi.com/api-providers or email us directly at support@rapidapi.com.
We're thrilled to announce the latest update to the Rapid Enterprise API Hub (version 2024.3)!…
Are you curious about what your API consumers are searching for? Is your Hub effectively…
The RapidAPI team is excited to announce the February 2024 update (version 2024.2) for the…
This January's release brings exciting features and improvements designed to empower you and your developers.…
Rapid API is committed to providing its users with the best possible experience, and the…
In today's fast-paced digital world, APIs (Application Programming Interfaces) have become the backbone of modern…
View Comments
Nice article, thanks for sharing your AWS knowledge
I was Googling around for content Add Authentication and Billing to Your API on AWS tutorial this morning, when I came across your excellent page.
Great stuff!!
I just wanted to say that your page helped me a ton. I would have never found any deep insight article on Add Authentication and Billing to Your API on AWS tutorial . I specially like you add flowchart of process,
It helps to learn EC2 cloud platform
It’s funny: I recently published top online resources to learn Aws tutorial.
Here it is in case you’d like to check it out: https://hackr.io/tutorials/learn-amazon-web-services-aws
Also, my tutorial might make a nice addition for learning Aws tutorial.
Either way, thanks. And have a great day!
Thanks Alex. Good one to read.
Glad you liked it! If there's any other content that you'd like to see a tutorial on definitely let us know.