API request with email in address path possible?


I’m currently implementing a API for a website which is supposed to
support following requests:
/api/users/email/[email protected]

Of course the email address with its dot causes an error because if the
.org which is interpreted as file format.

How can I pass an email address like that?

Thanks for the help,

Interesting question. First of all I think you need to change this a bit

/api/users/1 as the canonical url

and perhaps add a route like /api/users/search?email=youremail
which redirects to the canonical url.

Oh, yeah… I actually added the /id/ part by accident. So the only way
to pass an email is by a paramter like …?email=xxx?

makes sense, thanks a lot for the explanation :slight_smile:

It might be possible to pass it as part of the uri, but you do not want
do that because it would create a second url representing the same
Basically, you want to have one url per resource to make the API easy to
use, and for things that are actually queries it is better to use

Here is a simple example to illustrate the problem by adding voting to
user resource:

/users/email/[email protected]/votes

Which one is the correct one? Software developers would guess the first
but machines would be clueless. And you would have to implement both
to be consistent, then you would have to document it, and then you would
hate programming :slight_smile: