views:

154

answers:

7

What points i should consider while building a website, and planing to support users with API to use?

I see that most of famous websites are giving developers an API to deal with, such as facebook, twitter, google, ....

There are any general points i should consider while building a new website to be able to support developers with an API? "just very general points regardless the website service its self"

UPDATE all answers below helped me a lot.

+2  A: 

I imagine you would start off by identifying the functions (e.g., addUser, addStory, addComment, editXYZ, etc, depending on the type of website) that the websites supports, and the data that it provides (getCommentsForStory, getStories, getUser, ...), and creating a web service API for these functions, with appropriate security checks and so on.

If you've coded the website well, putting a web service layer in front of your website functionality should be quite simple (it's just another view on top of your controller and model).

JeeBee
+3  A: 

Soap or XML

Depending on your application. If it is complex you might need the functionality of soap. KISS should apply with APIs especially. Have a sensible URL layout that makes sense in terms of resources:

www.site.com/people/london

As a resource.

http://en.wikipedia.org/wiki/Restful

Look into why using PUT, POST, GET and others is important.

Good Luck

Aiden Bell
+1  A: 

One simple thing, that could save you a lot of hassle in the future - include the "API version" as part of your URL, something like..

www.example.com/api/v1/getAnswers/

If and when you decide to revise your API, you don't have to worry about all your URL's being backwards compatible (breaking existing applications), your users just start using /api/v2/ and you eventually depreciate the old version.

Among others, del.icio.us and github both do this

dbr
+2  A: 

The most compelling reason, IMO, to provide an API is that your site provides information and/or services that people will be motivated to interact with programmatically. Since you cannot prevent this (despite many site owners' hopes and dreams), it's better to embrace it, since providing an API means people can access exactly the information/services they want, reducing load on your systems.

chaos
+1  A: 

I recommend the complementary PDF and presentation of Joshua Bloch's "How To Design A Good API and Why it Matters".

lance
A: 

I was wondering If their would be any Script out their Which provides API functionality to any website By integrating that script on our website.

Shayan
you can post that as a new question not as an answer
Amr ElGarhy
A: 

building a good api is hard and needs a lot of practice.

the first api you build should be the api of your enemy's website.

the second api is for your friend's website.

the third api you build is for your customers.

Andreas Petersson