Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESTful way to check availability of usernames, emails, etc

Tags:

rest

I've recently gotten very into trying to think as RESTfully as possible, and I'm finding myself stymied by the non-obvious routes.

In this particular case, I'm curious about the RESTful way to check for username and email availability for a user, or anything else that has uniqueness.

My gut tells me that I would want to perform a GET on /users/email or /users/username/ each with a required param, or something along the lines of GET /users/search/ with optional params of email and username. If you get a 200, then the username or email is unavailable; if you get a 404, then it's available.

I prefer the first option since it's more explicit, but it's not like I've pored over Roy Fielding's thesis to know well enough what to do.

What's the most sound approach here?

like image 858
Josh Smith Avatar asked Aug 18 '13 17:08

Josh Smith


People also ask

How to check the availability of Gmail username?

So if you want to check the availability of Gmail username then you come to the right place. Here you can find the Free Gmail Username Availability tool that will help you to check if an email address is available for registration or not for free. Google’s Gsuite.

How to check user name availability using Ajax?

Explanation: As soon as username is entered in textbox the onchange event gets fired and username is passed to the checkUserName function which makes ajax call to the server side function “CheckUserNameAvailability” with the help of jquery.

How to check if an email address is available for free?

Here you can find the Free Gmail Username Availability tool that will help you to check if an email address is available for registration or not for free. This tool is working for Gmail, Yahoo, Hotmail, and Outlook. It also works for another custom domain-powered email service providers.

How do I find a good username for my website?

Start with several name ideas and type each one into the search bar. Namechk takes your username idea (even random words) and checks its availability as a domain name and username on dozens of social channels and online platforms. If the name is available on a certain channel, the channel turns green.


1 Answers

The first approach does seem to be more "RESTful". You try to GET a specific resource (by username or email) and get it if it exists or get a status message "unavailable resource". This would be:

  • GET /users/username/johnwayne (to "get" johnwayne resource/username availability...)

This should generate:

  • 200: if resource exists
  • 404: if the resource does not exist

The second one seems more like "SOAP"-like web service, where you define a "function" (/users/search/) with some "parameters" (username, email)...

like image 112
emgsilva Avatar answered Nov 29 '22 08:11

emgsilva