With APIs taking over, more people are asking: What can I use to create my API? Although there are many different API standards and types, we will primarily focus on REST APIs. An API can be as simple as a single endpoint with one purpose, or it can be much more complex, like the AWS APIs with 1000s of endpoints and 100s of thousands of users.
We like to classify the development of APIs in 3 phases: Design, Build and Host.
|Design||User requirements||Specification e.g. OpenAPI3|
|Build||Design specification||Working code|
|Host||Working code||API live 24×7|
INPUT: User Requirments. OUTPUT: Specification
During this phase, ensure that you create the API to fulfill a specific requirement. You need to take the user requirements for our API and transform them into a specification for our API. The result of this phase is usually some documentation and an API specification. The OpenAPI specification is produced in either JSON or YAML. A few tools can help you create your OpenAPI specification:
- Swagger: They have two options, the Swagger Editor (free to download) and Swagger hub (their hosted service). This service defines, visualises, and validates APIs in a collaborative environment.
- Postman: The most popular platform for testing and using APIs.
- Insomnia: A free cross-platform desktop application that takes the pain out of interacting with and designing HTTP-based APIs.
- Stoplight: Tooling across the API lifecycle that helps you build quality APIs efficiently.
INPUT: Design Specification. OUTPUT: Working code
Having defined what you need your API to do and have a specification, you can start building. For many, this is the fun part, creating the code that will execute when the API when called. Before starting any coding, ensure you know the logic you need to add to your API process.
Business Logic is commonly used to enable:
- Trigger automation such as email and push notifications on developer-defined changes in the data store.
- Optimizing the data exchange with the app by joining multiple data collections.
- Validating app user actions to enforce business rules.
- Providing a means to host platform-agnostic code and save development time on multi-platform apps.
There are quite a few options here. You can build your API with a full code framework such as NodeJS, Python: Django or ASP.NET. Another option is to build your API with a low-code API builder. A low code platform can allow you to quickly build the backend functionality of your API with pre-tested and proven components.
Before we get to building our API. Depending on your requirements, you might need to do a host of different things when your API is called. You may need to store data, send emails, use message queues, and more.
You will likely need to store data for your application. If you do not have an existing data storage platform, you might have some research to do. There are plenty of possibilities, each with its pros and cons.
- AWS: AWS has various database hosting options, most are scalable and flexible depending on your requirement, budget and technical ability.
- Azure: As with AWS, Azure also has several database options.
- MongoDB: MongoDB is a document database with scalability and flexibility for querying and indexing.
- MySQL: MySQL is an open-source relational database management system (RDBMS). It can be hosted on-premise, in the cloud (via a platform such as AWS or Azure), on a local machine or even in a docker container.
- PostgreSQL: PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language. PostgreSQL can be hosted on an on-premise server or by a service provider like AWS or Azure.
There are many other choices regarding data storage, be sure to pick the right one for you. A few things to consider are:
- Do I want to host the database myself, or will it be hosted in the cloud?
- Do I want to maintain the database myself?
- What speed and scalability do I want from my data storage?
You may also require some other utilities for your API, such as
You might be surprised at how much they can improve your development speed. The best way to try them is for your next small project. Pick something that you want to get out of the door quickly. Even better if you expect it to be primarily boilerplate.
If you choose to go with a full code framework, here are some of the frameworks you can choose from when
Another interesting angle is building ‘serverless’ functions using AWS Lambda or Azure functions to implement the API. The architectural complexity eats a lot of time, but building a couple of endpoints might be easy if you’re already familiar with those platforms.
Regardless of what approach or framework you choose, the outcome of this phase is working code that can be called to execute the API. For example, let’s say you require the API to return a data set from a data source (such as a database), the code will allow us to call an endpoint with a request body, and the code will retrieve the relevant data and return it to us. Since you are not hosting the API just yet, you will likely use “localhost”.
API Testing Tools
During the building phase, test your API to ensure it works properly.
- Use a web browser: If your API is simple enough, this is possible, you won’t get the best output, but it will work in a pinch.
- Hoppscotch.io: This tool makes testing your REST APIs much more manageable and is free to use when writing. It is a lightweight, web-based API development suite. It was built from the ground up with ease of use and accessibility, providing all the functionality needed for API developers with minimalist, unobtrusive UI.
INPUT: Working code. OUTPUT: API live 24×7
Now that your API is built and tested, you will need to ensure that it is reachable by your users. The simplest thing is to use a hosting platform that supports your programming language of choice, such as
Or in the low-code case, the low-code platform does the hosting. These platforms usually have a few options to choose from. For an on-premise server, you will also need to consider your ability to do so and the risks associated, as you will have to think of security and performance.
Further reading: Hosting APIs on the Linx Server