|
> I agree. However at this point it just seems a lot more work It's a lot more work for the end user to have to assemble URLs themselves instead of you providing them in the response. Let's say someone does a GET request on /tickets. The response should include URLs for each ticket that gets returned, e.g. something like: {
"tickets": [
{
"ticket_id": 1337,
"url": "/tickets/1337"
},
{
"ticket_id": 1336,
"url": "/tickets/1336"
}
]
}
Again, the analogy of the WWW itself is instructive. When you browse to the home page of a website, that page has links to the other pages on the site.Similarly, the home page of a REST web service should have links to the other resources on the web service, e.g. {
"resources": [
{
"resource_name": "Foos",
"url": "/foos"
},
{
"resource_name": "Bars",
"url": "/bars"
},
{
"resource_name": "Tickets",
"url": "/tickets"
}
]
}
That is simple, predictable, discoverable and self documenting for the end user. |
A question about resource discovery using links. In practice, does anyone write web service clients that use, and are driven by, link discovery? It seems to me that in a b2b scenario, an organisation that is going to be investing time and money in developing a client for an api will probably want some documentation to work against.
Also, is there a standard way to make discoverable the http methods that can be applied to a resource?