Why API
So you’ve been thinking about making an API and want to know if it’s the right things for you. There are a number of instances when an API doesn’t make sense, so it’s a good idea to research what is useful before you get started.
The first thing to consider is the size of your project. If your project is a small-scale website, you probably won’t need an API to accomplish your goals. If, however, you would like to make a rather large website, there are circumstances where an API would be worth the work you put in. You probably already know how much work can go into making an API. I’m personally a big fan of keeping things as simple as possible.
Here are four reasons you should consider an API:
1. Add a measure of security
If you anticipate having a lot of users use your website, you will possibly consider making an API. This is perhaps not the first consideration, but it is one. An API is more secure, because the data you send can not only be encrypted, but it can send information to a server that is never processed on the same machine. This means that if the security of one machine is compromised, the security of the other may not be. This added level of an API can protect you against those who wish to use your website for other reasons than what you intend.
2. Closed Environments
Having a closed environment is much of what adds to the security of the site, but not the only factor. The database, for example, can be on the API side, meaning that any stored database connection data is not visible on the actual site that the person is using. But this is not all. Having a closed environment gives you the opportunity to smooth out and minimize the amount of server activity that goes on. Ironing out the bugs first on the API is important, since it will only return things to other sites that you wish.
3. Platform Functionality
Once you’ve cleaned up the API and have it returning what you want, the greatest strength is in the ability of an API to play with other systems. That means that if you’re like me and love PHP, you can code your whole API in PHP and then an ASP developer can write the actual site and the connection to the server should be seamless. What’s more, you could even write the rest of the site on a different server entirely in HTML and JavaScript and use AJAX to get and post to the API without losing security.
What is perhaps even more relevant in cross-platform compatibility is that you can use API’s to connect the data on the server with mobile apps on Android, iOS, and any other mobile device you wish to use without needing to code another back-end. And you can, if your project continues to grow, document your API and allow other people to use your services. And all of the other services will still be secure.
4. Multiple Databases
Last, but not least, you can use multiple databases more easily if you’re interacting with an API. The API will use one (or more) database and your site will use another. This means that you have more control over where sensitive information is stored and if you’re using a framework, such as Kohana or WordPress, you don’t have to figure out how to run multiple configurations on one single site.