jeudi 15 juillet 2021

Addressing collection items in multiple ways in REST API design

We have a resource collection in our API design that can be addressed in multiple ways. For example say these are books.

ISBN ISSN Color
Foo 1 2
Bar 4 5
Baz 7 8

The books can be addressed uniquely via ISBN, ISSN and the name and color are non-unique indexs as well. How can we model a REST API that allows PATCH operations on the books collection/items that can be specified in multiple ways?

For example we may wish the clients to address the books in any of the following ways

  1. by book name
  2. by book color
  3. by book ISBN
  4. by book name and color

How can I do this without creating multiple endpoints?

Aucun commentaire:

Enregistrer un commentaire