'GitHub API: How to check for an organization's name availability?
I can send an HTTP request to the GitHub API to automate creating new or deleting repositories, delete repositories, etc.
For example, I can create a new repository like this:
curl --user "$user" "https://api.github.com/user/repos" -d {\"name\":\"$repo\"}"
I have been unable to any find documentation on how to create a new GitHub account or check if a user/organization name is available.
Solution 1:[1]
There is no way to create new users using the API. If you wanted to do this automatically, you would have to jump through a lot of hoops, including automatically confirming email addresses and you would probably be violating the TOS. Why would you want to do that?
Checking for usernames is much easier. To do this with the regular GitHub API, use:
curl -w '%{response_code}' 'https://api.github.com/users/<username>'
If it's a 404, the username should be available, assuming it meets all the username requirements (length, characters, etc).
An even easier way is to use what GitHub uses on its registration form:
curl --write-out ' %{http_code}\n' --data "value=$USERNAME" https://github.com/signup_check/username
This prints a little message if the username is unavailable and returns a 403. It returns 200 if it's available.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Huan |
