Hi Peter,
> The question centres around how to handle situations where a client application has multiple entry points, in particular if one wants to navigate straight to a resource which would otherwise require following a number of links from the root API entry point.
There is actually no such thing as an entry point of an API.
Sure, there is the one resource in your mind as an API designer that you consider "home";
however, that does not mean that this is the point through which clients will enter.
That's the whole point of the Web... any resource can link to any other resource,
and those resources do not have to be limited to a single API.
For instance, suppose my "nice places" application
wants to link to your "find flights" application.
If the user is currently browsing "London",
I'm not going to tell him or her:
"Well, here's the home page... and follow links X and Y, and click Z, and you'll be there".
No, I will link to your resource that has flights for London
(probably after having followed the links in your application myself).
This kind of passing the navigation path was common before the Web [1],
but should not be a practice nowadays.
Also, designing an API with a fixed navigation path in mind
lead to problems such as this one [2].
> Related to this question is the debate about how you allow third parties to save deep links direct to a specific resource without compromising the encapsulated nature of the API.
Well, you design your URI space in a way that allows to keep them constant.
The navigation still happens through hypermedia (and always will),
but the way you allocate URIs ensures you can maintain them in the long run [3].
Concluding, don't talk about "deep links". In a hypermedia world, that concept doesn't exist.
A link is a link, whether it happens to go to / or /flights/places/london.
Best,
Ruben
[1] http://ruben.verborgh.org/phd/hypermedia/#flyer
[2] https://gist.github.com/RubenVerborgh/7684361#comment-959892
[3] http://www.w3.org/Provider/Style/URI.html
--
You received this message because you are subscribed to a topic in the Google Groups "Hypermedia Web" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hypermedia-web/fWjqit3KtZQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hypermedia-we...@googlegroups.com.
To post to this group, send email to hyperme...@googlegroups.com.
Visit this group at http://groups.google.com/group/hypermedia-web.
For more options, visit https://groups.google.com/d/optout.
Hi Irakli,
Why not? Millions of telephone numbers have been constant for decades;
> I wouldn't mind at all if URIs were forever, it just isn't practical.
so have millions of e-mail addresses.
And it's actually easier to keep URIs constant if you control the domain name.
They're not. Physics describes the reality we happen to live in.
> REST and Hypermedia are like Physics: they describe the realities of the nature, we can't just invent the reality we want.
Web APIs we build ourselves. We're in control. We can design in a future-compatible way.
Just because many APIs didn't do it in the past, doesn't mean we shouldn't do it now.
> The [sad] reality is that URIs get broken all the time.
Sure (410 aside), and that's not a necessity to help me find my way.
> In reality the difference between "URL doesn't exist anymore" 404 and "never existed" 404 is not there.
No. It could be that the server has no clue what my old URL /news/london points to.
> "Old URLs" 404-ing do not give you information about what to do in the new world. If they did, they'd be 3xx responses.
But at least it can say: "look men, these are interesting resources I have right now".
If it has a clue what /news/london points to, then it's a 301.
And then it didn't break the URL. Hurray!
> If your API client always starts its navigation at /news/london/2014/03/15/articles/1 and that URL suddenly 404s--chances are you have no idea what to do.
Yep. That's why the 404 should tell me.
No need for a home, just follow links in the 404.
> At that point your only sensible "fallback" is to go back and check the Home of the API
Helpful 404s are a lot better. On my site, you never have to change a URL to get to any resource:
> It's a social contract. I know most of the time all of website's bookmarked URLs work, but if they break, the only thing I can rely on is that the root URL will still be there
http://ruben.verborgh.org/news/london
You don't have to know my home URL. Any URL of any resource that (n)ever existed on my API,
affords to access any other resource on my API.
Sadly, no agreement ;-) [really joking here, I like the interesting discussion]
> if you are saying "cache a 'deep resources' URL until it 404s', but don't hardcode it" then we are in agreement (despite our remaining differences on Linked Data view of URIs :)))
I say that, once a server has given you a URI, you can use it for eternity.
In the best case, it leads to the same resource.
In a slightly worse case, it redirects me to the same resource.
In the worst case*, it gives me an error page that allows me to reach any resource.
But never ever at any point do I need the URI of another resource to enter the API.
> Some other benefits to decoupling clients from the URL structure of an API:The issue is not about decoupling; like I said, the server determines the URL.
Instead, the question is about whether this URL remains constant during its lifetime.
Irakli,
besides URIs, another important aspect of Linked Data is RDF, which
Ruben failed to mention. In RDF, URIs are built into the data model.
If you build semantic applications using triplestore, you have a
database full of URIs. The HTTP API (Linked Data) simply reflects the
state of your RDF data. If your data is forever, then your URIs are
forever too.
This is actually a very generic and straightforward software design
pattern, but you have to try it to understand it. Good luck with
Hypermedia though.
> Some other benefits to decoupling clients from the URL structure of an API:The issue is not about decoupling; like I said, the server determines the URL.
Instead, the question is about whether this URL remains constant during its lifetime.
> In some cases, Not Found responses may provide an affordance for course correction.
They should in all cases. No reason not to do it.
--
You received this message because you are subscribed to the Google Groups "Hypermedia Web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hypermedia-we...@googlegroups.com.
Reading this thread with interest.
In order to be useful, the URIs in a response must have a lifetime greater than zero. Now we're just arguing the range between one and infinity.
Once you introduce 301, 404, 410 into the picture with the root uri as an escape hatch, it seems pretty well sewn up.
A client cannot construct URIs. Once obtained, they can be used until the server says stop.
Fair enough?
Gotcha.
Could include a "home" rel in every response in addition to other meaningful links. I think this gives some interesting affordances.
Also seems likes this model gives greater weight to a profile or self rel to be explicit about the media type in the response rather than relying on the rel that was accessed.
Thanks everyone for your contributions, I've learnt quite a bit from reading through the thread.
to provide some context for my original question, I was working on the assumption that a core principle of hypermedia APIs was that an API client should be able to rely on a published 'entry point' URI such as '/' and that it shouldn't make any further assumptions about resource URIs from that point on. Obviously you can have more than one 'known' URI, but the more you have, the more tightly coupled the client and server are.
If you think of the web as an example, I have no idea about what links exist within that website until I load the home page. Of course I can start guessing URIs and look at the responses to work out where to go from there, but I think having the 'entry point' of a homepage is a normal situation.
If I consider a client which isn't caching previously accessed resource URIs, then it must be either constructing URIs, or have some sort of 'entry point' to begin navigating the resource linkages.
I now understand better the 'deep linking' question - I should strive to maintain the provided URI for a resource that someone may want to reference directly and provide 3xx/4xx responses if I have to change it.
I was also under the impression that one of the benefits of the HATEOAS approach was that it helped me to address API versioning by allowing me to change the URI scheme in my API without worrying about clients that rely on out of band knowledge of the URI structure. So the discussion about not reusing a URI for a different resource isn't really relevant - I'm thinking more of the case where a new URI is defined for an existing resource.
I may post a more concrete example after I've discussed with the team.
Thanks!
Pete
.
.