Simple personal RESTful php api

The idea of a simple personal api is nothing new. Although I just came to know it a few months back. It immediately draw my attention because I thought it would be an amazing idea. The original inspiration was this post. Of course that api is implemented in node.js and I prefer to implement mine in php which I am more experienced in. After some time digging the internet I came across this. A lot of my code come from this post, so original credit to the author.

api_code_snippet

api_code_snippet

So, being an api, it does what you would expect it to do. You call it (you make a request), and it returns some data in JSON format (gives back a response). You must provide a valid api key to work. To prevent server abuse, currently only 40 api calls per key, per day are allowed. I don’t use a database because that would make it much more difficult than it needed to be. But by not using a database I also made it harder to maintain and scale, as everything need to be hardcoded into the code. If you are interested to see the source code visit my github page. The source code is fairly commented so you shouldn’t have any problem using it.
If you do use it however please make sure to insert your own information.

If you want to see it in action visit my website and press the API link in the right menu. Alternatively you could just visit this link and see it immediately in action.

0 comments