What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

By using one url in the client, you can do cool things like they did with the twitter API on Wordpress. One url also makes it easier to change the API.

You can have a page like this that allows the client to get the url it wants:

<ul>
  <li><a href="/questions" class="questions">All Questions</a></li>
  <li><a href="/users" class="users">All Users</a></li>
  <li><a href="/badges" class="badges">All Badges</a></li>
</ul>

This could of course even be integrated into the homepage itself. All the urls will be added on some page. The client can use hypertext to find the urls for their requests.

It also very possible this way to use the Content-Type and Accept HTTP headers to get a list of questions in a machine-readable format.

UPDATE

My request is based on the "Hypermedia as the engine of application state" idea. To find all the resources in the 'api' your client needs to understand HTML (or some other format that uses urls). You give one url to your client and it will find all the others resources/urls by getting HTML from this url. For example http://stackoverflow.com/ returns something like:

<ul>
  <li><a href="/questions" class="questions">All Questions</a></li>
  <li><a href="/users" class="users">All Users</a></li>
  <li><a href="/badges" class="badges">All Badges</a></li>
</ul>

Now your client knows abouts questions, users, and badges. It can now get /questions, which in turns returns:

<ul class="questions">
  <li><a href="/questions/1">How can I create an ArrayList in Java?</a></li>
  ...
</ul>

The client then could GET /questions/1 which returns the information you need, for example:

<h1 class="title">How can I create an ArrayList in Java?</h1>
<div class="question">...</div>

or an XML or JSON formatted response (that doesn't really matter for this).

The important point is that clients don't need to know about specific urls. The clients only need to know how to find the urls in the pages that contain them. This way there is less coupling between the client and the server.

share|improve this question
    
Is this a request for a more REST-ful API? Or something else? I don't understand the benefit of this. What client are you writing where these magic URLs would be helpful? –  Eilon Jan 18 '10 at 0:05
    
Yes, this is a request for a more REST-ful API. But as REST-ful means different things to different people, I just added part of what a REST-ful API would look like. Oh, and there is no magic involved, everything is visible in the 'View source' part of your browser. –  Peter Stuifzand Jan 18 '10 at 0:12
    
So the plan is to use CSS classes to identify groups of links? This has been tried before and is generally a bad idea. CSS is for specifying style, not for classifying an aspect of a URL. Jeff himself doesn't like it much and I agree with him on that point (codinghorror.com/blog/archives/001314.html). If anything, there could be rel="whatever" but that seems excessive. Nevertheless, SO already uses anchors with lots of rel attributes. Could it be that your feature request already exists? –  Eilon Jan 18 '10 at 0:17
    
It's an allowed use according to the HTML4 standard (w3.org/TR/html401/struct/global.html#h-7.5.2 "For general purpose processing by user agents."). Sure, that's not an actual argument, but it's in accordance with the spec writers idea about classes. Also, classes are used in other places by Javascript to add events to elements. So, saying that classes are only to be used for styling is not true. –  Peter Stuifzand Jan 18 '10 at 10:17

You must log in to answer this question.

Browse other questions tagged .