RAML to get collection item more than one way


#1

Hi, newbie questions here.

I am familiar with the common pattern:

/collection

/{collection_id}

But if there are more than one way to get an item, how would the RAML define:

/collection

/{collection_id}

/[get by parameters 1, 2, and 3]

For example, you can get a person by their id; or by the complete set of firstname, lastname and date of birth.

Is the basic idea that a new nested resource would need to be defined for each way items can be retrieved?

But then can you have more than one resource nested under the main collection?

E.g., could you have different methods defined such as:

http://myapibaseuri.com/people/
http://myapibaseuri.com/people/id
http://myapibaseuri.com/people/demographics/?firstname=bill&lastname=smith&dob=01/01/1901
http://myapibaseuri.com/people/country/usa

Thanks!


#3

Hi,
Yes, you use indentation to nest as much REST based uris as you need. To define something similar to your example you could use:


#4

Yes definitely there are a lot of methods by which you can identify a particular record.
In your example using {CollectionID} you can find the record but you can also filter the collection using some other parameters such as {Album} , or {Genre} or by {Artist} or by {Language} or by {Year released} to sort your results for a list of songs


#5

yes, you can have more than one resource nested under the main collection. and you can use the resource as /{collection_id} to set each item data.