API Basics explains what we do with this API and why and how really you can use your own API. It is really not that difficult than it sounds to be. We wrote about API or Application programming interface in details in an article, how to test your Cloud Based App RESTful API, you have heard of WordPress API, this API, that API; but basically you never understood what this API is. If your understanding with API is like this situation, this light article on API Basics will definitely help you. This article API Basics not only explains but provides easy examples to build something of your own.
API is a specification for a particular application that returns a set of functions for a specific task to interact with a specific software component. Sounds difficult ? Look, API can be very simple or very very complex. An API call might require privileged access (that means you will need some key to read it) or can be generally, publicly accessible. Quickly read this relatively unrelated guide – Find Your Facebook Fan Page ID and Facebook Profile ID Easily. You have heard that Facebook has API. Now, you want to know the number of Likes this website’s Facebook page. Well, you can do it by directly going to the real webpage on Facebook via browser. But just to know the number, what is the need of loading a whole webpage ?
Facebook describes here how to use such way :
Practical example for the above situation to know our Facebook Page’s Fan number is to go to this URL :
Depending upon your Operating System, you will get it on browser result of array of data or you will prompted to save, save as text file. This is not meant to be directly read by you or me, it is intended for the programs which can easily get the data. If you are using OS X or Linux, you can open your Terminal App and also fetch the data in this way :
This returns this result :
So, without using browser we actually can know many data of our Facebook page. What is the use ? The use is for example to show it on Widgets or kind of such things. We need to use some programming language for that part. For example, Twitter follow button with follower number, the scripted thing will be :
That will return this : Follow @AbhishekCTRL
API Basics : Create a Simple Own API
This is a very basic example set :
This is intended for PHP, but can be modified and used in Ruby. In fact, the Syntax highlighting is with Ruby as there is no PHP opening tag. So, first you need to know some programming language, otherwise how you will write your own logics ? If you know the language, its simple like the above, you just need to keep it open, and provide a browser accessible output url. From $this -> $txt or from $that -> $json.
We should stop here in this guide because this is just the API Basics.
Follow the Author of this article :