views:

69

answers:

4

I have a dataset and I want to create an API (RESTful web service) around it. However, I don't want to start from scratch as I believe this has been done zillions of times already.

Does anybody know any well-tested service that has opensourced its API? I see that people normally release a reference implementation for their clients (like Digg, or Google's GData clients) but I haven't found so far any API code released as Open Source.

A: 

That's because releasing the API source would literally be releasing their internal details and data models (aka. trade secrets) :-) I'm not sure you'll find anything aside from maybe descriptions in engineering interviews of the technology they used.

Joel Martinez
Is that so? I understand the value normally is in the data itself more than in the data model--which can be decently inferred from the methods/parameters documented information.
zugaldia
an "API" is rarely just a data model. having a peek at the actual implementation will reveal internal details about the company's development environment including (potentially) database schema details that may be used to discern an attack on the company. I'm certain that you can argue for or against these fears ... but they are fears that many companies have nonetheless :-)
Joel Martinez
A: 

Um there are many frameworks for dealing with REST. There are many ways to approach the problem as well.

Basically accept an HTTP request. The request could be like a regular web request, why not. The response, instead of html, would be XML, JSON, or anything that is easily understood (or you can have ".xml" for xml output, .json for json output. Ruby has lots of this behavior out-of-the-box.

The real work of REST is the serialization. I mean in one of my former jobs we converted a regular html server to serve most things as rest by replacing the view layer with something that outputs serialized objects. You can also accept input as JSON or XML or whatever by asking for a "content" paramater to contain the requested JSON.

Thats the beauty of REST, it could be very very simplistic. Just see what your users want to communicate in.

So in any case, check out Ruby on Rails' REST stuff. What language are you coding in anyways?

Dmitriy Likhten
Frameworks tend to be generic and strongly focused for MVC apps which will eventually show a HTML page. As you say, you can always make the view to dump XML or JSON, but that won't necessarily include the elements you have in a working API (like, let's say, a cache layer).Are you aware of any framework specifically designed for APIs, or even better, an actual API implemented with one of these frameworks? Python, RoR, or PHP would work.
zugaldia
Wait, I am sorry for not following, how is MVC not taking a cache layer into account? I thought RoR has a pretty good caching mechanism when combined with memcached and the memcached extension.http://github.com/seattlerb/cached_model for caching in rails...
Dmitriy Likhten
+1  A: 

If you have access to a Windows server and it's just data you want to expose then look at OData http://odataprimer.com

Darrel Miller
Thanks Darrel, that's the kind of information I've already found. My interest is focused in finding an actual implementation using OData, like if Netflix had released their OData API code (which I believe isn't the case).
zugaldia
@zugaldia 98% of the code you need to provide an OData service is in the WCF Data Services Library. Here is a tutorial http://msdn.microsoft.com/en-us/magazine/ff872392.aspx
Darrel Miller
@zugaldia Here is my example of the simplest OData service possible http://www.bizcoder.com/index.php/2010/03/26/worlds-simplest-odata-service/
Darrel Miller
@Darrel Miller Still not what I'm looking for because it's far to be ready for production, but it's appreciated, interesting code to quickly learn more about OData.
zugaldia
A: 

This is commonly being done with Java Enterprise Edition (Java EE). I've recently finished a series of blog posts that demonstrate how to leverage the different Java EE standards to accomplish this.

This particular example uses the GlassFish application server. For larger deployments I would suggest using WebLogic.

Blaise Doughan