views:

130

answers:

3

Hello,

I'm a new REST convert and I'm trying to design my first RESTful (hopefully) api and here is my question about addressing resources

Some notes first:

  • The data described here are 3d render jobs
  • A user (graphics company) has multiple projects.
  • A project has multiple render jobs.
  • A render job has multiple frames.
  • There is a hierarchy enforced in the data (1 render job belongs to one project, to one user)

How's this for naming my resourses...?

https:/api.myrenderjobsite.com/

/users/graphicscompany/projects
/users/graphicscompany/projects/112233
/users/graphicscompany/projects/112233/renders/
/users/graphicscompany/projects/112233/renders/889900
/users/graphicscompany/projects/112233/renders/889900/frames/0004

OR a shortened address for renders?

/users/graphicscompany/renders/889900
/users/graphicscompany/renders/889900/frames/0004

OR should I shorten (even more) the address if possible, omitting the user when not needed...?

/projects/112233/
/renders/889900/
/renders/889900/frames/0004

THANK YOU!

A: 

Personally I would not try to squeeze path too much, that is, some amount of redundant information is helpful both to quickly see what resource is, and for future expansion. Generally users won't be typing paths anyway, so verbosity is not all that bad.

StaxMan
A: 

Presuming that you authenticate to the service, I would use the 1st option, but remove the user, particularly if the user is the currently logged in user.

If user actually represents something else (like client), I would include it, but not if it simply designates the currently logged in user. Agree with StaxMan, though, don't worry too much about squeezing the paths, as readability is key in RESTful APIs.

Deeksy
+1  A: 
Darrel Miller