GET /instances/instance_id/ to get instance information
POST /instances/instance_id/logs to create a new log item.GET /instance to get instance information for his own instance
POST /instance/log to create a new log item for his own instance--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
That seems fine to me. There's no reason you can't have multiple URIs that reference the same resource.
I might be thinking wrong but I think you can run into potential caching issues if you do that. Consider this series of requests:GET /my-instancePUT /instance/<my-instance-id>GET /my-instanceIf I'm not mistaken and HTTP caching is being used the 2nd GET will think it has a current copy but it will actually be out of date.Maybe someone else who has more real-world experience on this specific topic can chime in?
M
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
Mike,
I think those are valid trade offs to weigh into your decision. And I wouldn't argue that the most performant solution would be to have the client use what it knows to generate the call, but it is not without its complexities.
- you can't change that URL
- you add complexity to the client (albeit very little in this case) to construct the URL.
These may be the right risks to take in some circumstances but I am not sure it is always right.
To your point about clients not obeying 3xx redirects, I mostly reject it. Most clients do this out of the box, and those that don't it is just another API interface that needs to be agreed to, in my mind no different they telling them how to construct a URL, or that they need to send a PUT instead of a POST.
The extra network hop is something to consider in your design. If you instead had both URLs work you would have the potential caching problem to worry about, but depending on your use case is a non issue.
And in some cases the client won't know the data that should go in the URL. I like to use the example of most recent. Imagine I have a set of documents I manage
/documents/<document-id>
And I also have a feature where I keep track of the last document that was edited for client to reference.
/users/<user-id>/most-recent-document
In this case the client doesn't know what the most recent document-id is, because the server keeps track of that state for it. You could have the /users/<user-id>/most-recent-document be the resource you interact with exclusively but that makes purging caches and sharing updates between users very difficult. Instead you would want to have this resource reference the most recent document, or perform a redirect (either case does require two hops).
That is all a bit of a tangent from Jack's Original question, so maybe if we want to continue that conversation we should spin off the thread, instead of hi-jacking this one.
-Daniel
@Mike: Good thinking :)I actually plan to do something similar to Facebook by using ETags. Due to the nature of the system, data can change often, so using expires for caching is unsafe. This, means however, that I am not saving on requests (each requests needs to be validated against the server), but I think it is a good compromise.@Ted: Yes, that was one of the reasons why I started this discussion :) My reason for the shortened URIs are:
- It is very simple to access your own information without having to build a URI or know your instance_id
- Facebook is using them, so it might be offering something of value to clients/api consumers.
- Github, which has a pretty beautiful API in my opinion (unlike twitter's ugly API) also has something like this: /users/user_id to get a user in the system and /user to get the authenticated user.
The disadvantages are of course as you have mentioned:
- The URI points to different things which is probably unrestful.
--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group, send email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.