Question

I would like to know if there is some best practices about the root endpoint for a REST web service? I mean, should it be a short documentation about the usage of the API itself? Should it be an XML document describing all methods available? Should it only return "unknown method"?

Was it helpful?

Solution

This question as asked is unclear. I would guess it means something like a directory that all API methods are under. For example, the root directory of the Flickr API would be http://api.flickr.com/services/rest/.

For an example of a project that accesses the Flickr API, see python-flickrapi

OTHER TIPS

The question is perfectly clear to me.

I think it should respond with 404. If there is no resource associated with the root path, then there is nothing to return.

If you feel that 404 is not helpful, then it would also be OK to return the URL of the documentation.


1. NerdDinner uses WCF Data Services, which is a great way to correctly implement RESTful services. The reason I am point to that, and not WCF data services directly is because it is a public website and you can use it. 2. MediaWiki is not a great example because they are passing actions in the URI but it is technically a RESTful service and show's a lot of interesting ideas.

the rootend point of REST API is the the API defined for the first slash i.e "/" of the url after the dispatcher-servlet. It contains all the GET for the list of resources (mostly the get for all the database tables) this list further contains all the items and in single item there will be DELETE , PUT/PATCH and SELF get URL. Thus making the implementation of HATEOS.

REST is supposed to be self describing so having the root show an error is poor design in my opinion. I like the root to contain information that allows you to navigate the rest of the API. So for example the root might contain a link to a list of product categories from which the API user can select a category and then a list of products etc. A self describing API means less documentation to write and keep updated!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top