Composite ID REST API Design

What is the best way to create a RESTful resource for a compound id object? For example, suppose I have a resource GET /people

to get a list of people posts. The person has no identifiers; instead, it is identified by firstName, lastName, and date of birth. How do I create a resource to get one person?

+3


source to share


3 answers


I would use one of the following:

GET /people/John/Smith/1973-12-01

      



or

GET /people/John,Smith,1973-12-01

      

+3


source


What about:



GET /people/firstName/X/lastName/Y/birthdate/AAAA-MM-DD

      

0


source


As mentioned in the comments, if you don't have a single identifier that enforces uniqueness, you can consider matrix variables:

GET /people;firstname=John;lastname=Smith;birthday=1973-12-01

      

0


source







All Articles