tags:

views:

112

answers:

2

In my 4 years of experience,I have developed a lot of web applications. Now, the concept of programmable web getting more and more popular, new APIs are being released almost everyday. I would like to develop a java API/library for a few of these endpoints.Ex stackapps,reddit,digg etc... What I would like to know from you people is ,

  • How is the API of the regular web apps differ from the API of these libraries. Or what is the difference between these two from design perspective
  • What are the best API development practices.
  • What are all the factors that I need to consider before designing the API

.

Please comment, if the details are not sufficient.

+1  A: 

From my experience, all good API were not made to solve a generic problem, but to solve a problem for some that requires a certain abstraction. This abstraction is then evolving as the requirement and/or the underlying layer change.

So instead of finding the API that will do it all, I'd start by finding one or two good case problem were your API could help.

Wernight
I don't think he wants to find or even create a new an API, but make a wrapper around an existing API to make the web invisible. Is this correct, chedine?
Thomas Owens
No.I want to create an API. For ex, digg has announced its HTTP endpoints to access its resouces. I would like to build a open source java API which can connect to these endpoints under the hood.
chedine
Still the same issue. You cannot simply have an interface that aggregates everything, right? You cannot either simply take the common stuff and leave the specialized stuff aside. If that's about making a wrapper that support various websites API, then isn't it an API by itself?
Wernight
@chedine: So you're looking for a Java API to use various website API like Facebook, StackExchange...?
Wernight
Correct. It's an API by itself. And my question is about the design principles and practices to be followed during an API development.Since it will be open for public,I can't design it my way right?
chedine
@Wernight - Lets leave the app that the API is trying to communicate with. What are the good practices in general?
chedine
Let me simply say this: When you design you have thousand of ways. To decide which one to take, you need to have criteria to guide your decisions. Without a clear objective of what problem your API solves, you wont be able to answer those questions.
Wernight
+5  A: 

Stability

If you offer an API to your web app, it is probably because you want other people to build applications using it. If it is not stable they will hate you for forcing them to follow through your frequent changes. If this takes too long, their site might remain non-functional for a long time while they are figuring out the new way of doing things in your API.

Compactness

You want the API to be complete but compact, as in not too much to remember.

Orthogonality

Design it so there is one and only one way to change each property or trigger an action. Actions in an orthogonal API should have minimal (if ever) side effects.

Also, it's not a good practice to remove a feature from a public API once released.

Security and Authentication

Since the API is web-exposed, you will have to authenticate each request and grant appropriate access. Security common sense applies here.

Fast Responses or Break into pieces

I believe in a web environment we should have fast responses and avoid requests that will take too long to complete. If it's unavoidable then it is better to send an ACK and break the task into several pieces and subsequent calls.

Bakkal