As a programmer, I really appreciate sites that provide APIs.<p>I'm building a music recommendation web app and I've just started creating an API (http://theperceptron.com/api) for it. However, is this too early? The very core of my app is there, but there is plenty on my todo list (I'm only a week into development). What priority should I give the API?
I'm building an app and found that thinking about the API from the get go made me design the app better. Why? Because the interface I'm building is just one example of how to interact with the API. The API is better and I understand my app better.
I think it's way too early for an API, and here's why:<p>- API's are generally only interesting if there are already some users, accounts, etc. to interact with.<p>- API's are not a main feature of the site (I could be wrong here of course) and are quite a way down the list. Fix the obvious problems first. I searched for Dire Straits and got no results.<p>- API's aren't used by a lot of people.<p>Basically what I'm saying is that you should get your priorities straight: An API has no value before the rest of your site works well, and has a lot of users.
I would recommend checking out Tom Coates' "Web of Data" talk. Presentation: <a href="http://www.plasticbag.org/files/native/" rel="nofollow">http://www.plasticbag.org/files/native/</a> Audio: <a href="http://www.webuser.co.uk/carsonworkshops/TomCoates.mp3" rel="nofollow">http://www.webuser.co.uk/carsonworkshops/TomCoates.mp3</a><p>It explains that the data is the web site (app), or at least the most important part of it. By building a web app on top of an API you are immediately exposing the unique and interesting part of your service, the data.<p>This leaves you, or anyone else, free to build whatever interface on top of that data. At Yahoo we absolutely use our own APIs internally to build our sites. That means most of the APIs we make publicly available are the ones our own developers have been using.
Interestingly, I was wondering the same thing!<p>I wouldn't call what I'm doing much of a web app (<a href="http://scribbleit.net" rel="nofollow">http://scribbleit.net</a>), but I wanted to learn some basic PHP so I decided to create a to-do list app (wow, new idea huh?) because I hate all the alternatives out there.<p>I had just finished hacking a bunch of PHP scripts to get all the functionality and then a friend of mine said, "Hey, I actually want to use this... if I could make an iPhone app for it!"<p>Long story even longer (sorry), I've started implementing an API just because I think it's the right thing to do. It's allowing me to understand my application a bit better and proving to be a great learning point for me.<p>In generality, I can only see an API introduced early as a major advantage. It can give you a direction for your design and future development. Oh, yeah, and the purpose of the API .. it will allow people to interact with your application in ways you possibly didn't imagine; there'll always be someone out there who would be interested in playing about with it!<p>Just my $0.02. Sorry for rambling.
Maybe working out the API will allow you a good second angle into how your app should interface with the world (next to the user interface, obviously)?
The purpose of an API is to provide a way to build an application. If you build your website on top of your own API, then you've already shown off what you can do with your API, which is great.
If your application is something for whom an API is useful, then encapsulate the application behind your API. This will allow you deal with the application at a somewhat abstract level, which will lead to better programming practises. So, write your tentative API first, program for the API, test with rough mock-ups, then write the front end.
An RSS/Atom feed is usually fairly easy to build and can make for a decent read-only API. You can add your own namespace or use microformats for app-specific data.<p>It might also make sense in your app as the more common "subscribe" use - a user might subscribe to get recommendations for new artists that fit her taste etc.
If you're using MVC or similar framework then adding an api is a simple case of adding some alternate views. Adding these is a handy way to check if you're keeping your code all neatly partitioned.