What steps/processes will I need to take to plan the creation of an API for my website (that uses PHP and SQL technology)? Also, what information will I need to know?
For an example, Step 1: Create index page, Step 2: Create this set of or library code, etc…
I am creating a social networking site from scratch that I would like to implement a API with during the alpha phase. I assume I will need to make the application object oriented which I have no problem doing. But where exactly do you start in the API implementation process?
Very first of all: decide why you really need this API. If you’re going to produce some client app that uses this API itself, that’s a good reason. If you’re just hoping that somebody will use that API to do interesting things once your service hopefully becomes popular, that’s a bad reason. You’ll just be spending a long time working on the API without anybody ever wanting to use it. Make your service popular and gauge the interest in an API first.
Having said that, an API is just yet another URL on your site where you serve up data in structured, machine readable XML or JSON (or another format), it is not fundamentally anything different from an HTML document served up for your regular pages.
The main difference is that the API needs to be well designed and stable. You can redesign your HTML anytime on a whim, but once a client is written to use your API, it should not change for some time to come. So you’ll need to plan the usage and data format of the API well. This is easier if you have a good idea what it will be used for. Study existing APIs of other large services in detail to see how they solved some of the details.
Internally you will want to structure your application modularly. Properly separate concerns using, for instance, the MVC pattern. You will have your core logic in your Models and you will have two (or more) Views; one regular HTML view and a JSON/XML API view for largely the same data. That means: don’t mix any important logic with your HTML which you’d have to duplicate in your API views.