One API to rule them all

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.

  • Python
  • Ruby
  • .NET / C#
  • Java
  • Perl
  • Node / JavaScript

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:

  • Trivago
  • BlaBlaCar
  • National Geographic Play

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.

  1. 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.
  2. 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.
  3. 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

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

By Niek Khasuntsev. Niek is a programmer at El Niño

http://www.elnino.tech. Digital Development Agency building tailor made solutions, ensuring success by making it measurable.