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.
In the top right corner of GitHub.com, click your profile photo, then click Your organizations.
In the top-right corner of GitHub Enterprise Server, click your profile photo, then click Enterprise settings. In the enterprise sidebar, click Policies. Under Policies, click Options. Under "Default organization membership visibility", use the drop-down menu, and click Private or Public.
Create an async function getUsers(names) , that gets an array of GitHub logins, fetches the users from GitHub and returns an array of GitHub users. The GitHub url with user information for the given USERNAME is: https://api.github.com/users/USERNAME . There's a test example in the sandbox.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With