Currently I have the following resource:
/api/user/12
returns information about user with id=12
/api/user/12/trips
returns a list of trips made by user 12 and their information
However I consider /trip/ a separate resource, so this would continue like this:
/api/trip/5
returns information about trip with id=5
Is this a good way to do this?
The best practice is to use the path to the domains.
To show a certain user:
To show all the users:
Use query for filtering all the users.
Here a nice article: http://developer.immobilienscout24.de/wiki/Path_and_Query_Parameters
You should always use plural to name resources:
Meaning: all users (collection).
Meaning: user 12.
For nested resources related to a given resource, you can do:
Meaning: all
trips
foruser
12.But, you still can describe a specific
trip
using this URI:Meaning: trip 5.