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?
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
tripsforuser12.But, you still can describe a specific
tripusing this URI:Meaning: trip 5.