Designing of Restful-URI

Want to share a good article about REST-URI design which may be useful for those who new in REST.

http://blog.2partsmagic.com/restful-uri-design/

In short, author points to:
  1. URI should be human readable and easily guessed.
  2. Each part should be meaningful. All URI parts together should be good nested, and help visualize the site structure.
    • http://example.com/cars/alfa-romeos/gt
  3. Nouns, not verbs.
  4. Resource Names: prefer to use lower-case and hyphen instead of spaces.
    • http://example.com/tasks/by-a-new-car
  5. Resource IDs: prefer to use additional meaning prefix.
    • http://example.com/tasks/task-17
    • http://example.com/conversations/conversation-{id}/todo-list-{id}/todo-{id} 
  6. Query args should used for querying/searching resources (exclusively). 
    • http://example.com/tasks?created=2009-04-26&group=major
  7. No special chars or file extensions (.php, .aspx) if they are not meaningful.
  8. Permanent. Should not be changed with time.
  9. Context friendly.
    • http://example.com/users/current/details vs. http://example.com/users/user-anton/details
    • http://example.com/forecasts/cambridge/today  may redirects to, say, http://example.com/forecasts/cambridge/2009-04-26
I am fully agree with author - designing of Rest-URI it is more an art than a science.

Comments