
As a starting web developer, APIs were the first things that I learned about. Proper use of an API will make every web developer a happier person, and in this article I will try to explain why.
What is an API?
If you are new to software development you might wonder what an API is. Which is a good question. Even for experienced developers this can be a though question, because of misuse and sometimes abuse of the term API. It can be really confusing to understand and explain the true meaning of it.
API stands for Application Programming Interface. According to wikipedia the definition is: “An API is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components”
While the explanation is clear and correct, it is outdated. Nowadays APIs are much more that that.
Some time ago, a new trend started to arise in the world of software development. Web startups started to offer public access to some parts of their internal data. This was done through a web service API. This was usually achieved through the use of REST and JSON. Soon web developers started using the term “API” to mean specifically (and only) “publicly accessible web service”, and misusing it to include the implementation thereof.
A little while later, the API started to replace the traditional back end of a software system. This opened up new possibilities which brought their advantages with them. More on this later.
APIs can be created in almost any programming language. The most popular languages are however:
- PHP
- Python
- Ruby
- .NET / C#
- Java
- Perl
- Node / JavaScript
All these languages either have frameworks and / or libraries available to complement them, and make the life of the developer a lot easier.

Our language and framework of choice: PHP + Symfony
For the API our go to language was PHP with the Symfony framework (version 3.2 to be specific). For those of you who are not familiar with symfony. The explanation on their own site states:
“Symfony is a set of PHP Components, a Web Application framework, a Philosophy, and a Community — all working together in harmony.”
Some notable companies that use Symfony are:
- Spotify
- Trivago
- BlaBlaCar
- National Geographic Play
As you can see the framework is widespread and used for a lot of big projects. A lot more than are listed. Add the fact that it is open source and has more than 1400 contributors, and you get a strong and reliable framework.
Advantages of an API Backend
For our latest project we needed to develop a cross-platform application. Which would run natively on IOS and Android, but should also be usable on the web. As you could read in Ricks blogpost about React, we found a way to make the frontend development process as efficient as possible. For the backend we needed a similar solution.
All the different applications (Android, IOS, and Web) essentially needed to have the same functionalities. So to save time, remove code duplications and make the backend as maintainable as possible we decided to use a centralised backend in the form of an API.
So instead of three different backends, we just build one API which will handle all the interaction with the database. In other words: One API to rule them all. This includes the following actions:
- Creation of accounts. To use our application registration is mandatory. This means creating accounts needs to be possible. The API handles the creation of new accounts and makes sure that the account can be used after creation. This is done with the needed information that is delivered by the front end.
- Authorization of users. Once the account is created and activated successfully, the user should be able to login. The frontend delivers the credentials that the user provides. The API checks the credentials, if they are correct a JSON Web Token is returned (Discussed in detail in previous.
- Handling personal information. In our case each user could save additional information about him/her. This was also handled by the API. Because the front end is not allowed to perform actions on the database.
- Validating all input. Validating input is always a good idea and you can never have enough of it. The API checks the input and if necessary returns corresponding error messages
All the information that is needed for the above described functions is provided by the frontend in the form of a JSON message in the POST request body.
Conclusion
If you need to build a cross-platform application which will mostly rely on the same functionalities, it might be worth trying the API Backend approach. It might save you lots of time and effort
