jeudi 7 septembre 2017

Support different identifiers in REST APIs

Im designing a REST API for a simple resource called User that basically allows the querying of user information.

The User resource has attributes such as id, email, username e.t.c.

To GET a user based on an id the best practice that I have seen is

/api/user/{id} such as /api/user/1

which is fine and very obvious.

What is then the recommended approach for getting a user based on an email ?

I have seen several patterns so far such as

  • /api/user?email={email}

  • /api/user/email/{email}

  • /api/user/{email}/email

I've come across this post REST API DESIGN - Getting a resource through REST with different parameters but same url pattern which has some relevant information but still confused about the pattern

Any thoughts about this ?

Aucun commentaire:

Enregistrer un commentaire