Search the web
Sign In
New User? Sign Up
rest-discuss · REST Discussion Mailing List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
On <link> (API design)   Message List  
Reply | Forward Message #11368 of 14004 |
Hello,

I'm having a hard time designing a restful domain specific XML
vocabulary. How should I link to other resources and others
representations of the resource itself? Atom uses the <link> element,
which is very extensible. But that's its problem, if I am designing a
domain specific vocab, why should I try to be generic? Consider a
client resource. Which may have a collection of orders associated with
it. If I were to point to a resource containing the client's orders, I
could use <link> as follows:

<link rel="orders" type="text/xml" href="/api/client/123/orders.xml" />

The problem I have with that is unnecessary complexity. I'm using a
construct that is clearly intended to be used in broad, extensible
context in a domain specific API that is supposed to be set in stone.
I'm inclined to just use the following:

<client ref="/api/clients/123">
<orders ref="/api/clients/123/orders.xml" type="application/xml" />
<orders ref="/api/clients/123/orders.json" type="application/json" />
</client>

I could definitely find a way to wrap the API in Atom (since
everything are basically collections), and in this case of course I
would use <link>. But if I'm defining my own domain specific API, from
an engineering point of view, should I care with keeping consistency
with Atom/HTML on <link> and potentially also attribute names (ref vs
href)?

I have come up with two postulates for API design, so whenever I would
run into the same type of situation, I would these criteria to guide
myself:

1) Every referred resource within another resource's representation
needs a @ref attribute pointing to its canonical representation
(usually XML), even if it is an empty element, and also a @type
attribute. Example:

<other-resource ref="{uri}" type="application/xml" />

2) Every URI pointing to an alternative representation of the current
resource should be kept as text element children. Naming of the
element for the alternative representation is up to the API specific
domain. Example:

<track ref="/api/tracks/123">
...
<media bitrate="128kbps" type="audio/mpeg">http://...</media>
</track>

What you think of this convention? Am I making any sense here?

--
Jonas Galvez
Software Engineer
Côdeazur Brasil

http://jonasgalvez.com.br
http://codeazur.com.br



Wed Oct 1, 2008 4:13 am

jonasgalvez
Offline Offline
Send Email Send Email

Forward
Message #11368 of 14004 |
Expand Messages Author Sort by Date

Hello, I'm having a hard time designing a restful domain specific XML vocabulary. How should I link to other resources and others representations of the...
Jonas Galvez
jonasgalvez
Offline Send Email
Oct 7, 2008
1:31 pm

What is so complex about using the first choice below? Subbu ... http://subbu.org...
Subbu Allamaraju
sallamar
Online Now Send Email
Oct 7, 2008
9:27 pm

... I believe <link> is too generic/extensible, designed so that you can fully describe a link only with attributes instead of having to define new XML...
Jonas Galvez
jonasgalvez
Offline Send Email
Oct 7, 2008
10:57 pm

Jonas: While there is nothing wrong w/ inventing your own XML vocab (and the validators to support it), I think there is not much to gain in doing so. Using...
mike amundsen
mamund
Offline Send Email
Oct 7, 2008
11:13 pm

... Well, I'm sure there are lots of HTML and Atom libraries that handle <link> automatically but unless my API's XML vocab is a direct extension of either...
Jonas Galvez
jonasgalvez
Offline Send Email
Oct 8, 2008
12:11 am

... In certain cases, your proposal can simplify client implementations. Instead of getting a "link" child and then getting its "href" attribute, the client...
Subbu Allamaraju
sallamar
Online Now Send Email
Oct 8, 2008
12:43 am

... That doesn’t seem like a concern to me. The basic link element pattern is trivial to handle. The complexity in handling links is in dealing with the...
Aristotle Pagaltzis
a22pag
Offline Send Email
Oct 9, 2008
3:51 pm

Hi Jonas, I prefer the link element specifically because it's more generic. E.g. in your example … <link rel="orders" type="text/xml"...
Stefan Tilkov
stilkov
Offline Send Email
Oct 8, 2008
10:20 am

... "application/vnd.myorg.orders+xml"? Although such a media type is proprietary, it can be used to describe representations more formally instead of...
Subbu Allamaraju
sallamar
Online Now Send Email
Oct 8, 2008
5:02 pm

... I agree and like this much better than application/xml. Still, text/ xml is worst: http://www.w3.org/TR/2004/REC-webarch-20041215/#xml-media-types Stefan ...
Stefan Tilkov
stilkov
Offline Send Email
Oct 8, 2008
7:46 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help