What is github-username?
The github-username npm package is a simple utility that allows you to retrieve a GitHub username from an email address. This can be particularly useful for applications that need to map email addresses to GitHub profiles.
What are github-username's main functionalities?
Retrieve GitHub Username
This feature allows you to retrieve the GitHub username associated with a given email address. The code sample demonstrates how to use the package to get the username asynchronously.
const githubUsername = require('github-username');
(async () => {
const username = await githubUsername('email@example.com');
console.log(username);
})();
Other packages similar to github-username
gh-user
The gh-user package allows you to fetch detailed information about a GitHub user by their username. Unlike github-username, which maps an email to a username, gh-user provides more comprehensive user data such as name, bio, and repositories.
github-api
The github-api package is a more general-purpose library for interacting with the GitHub API. It allows you to perform a wide range of actions, including fetching user data, repositories, and issues. While it can be used to get user information, it requires more setup and is not as specialized as github-username.
octokit
Octokit is the official GitHub REST API client for JavaScript. It provides a comprehensive set of tools for interacting with GitHub's API, including user data retrieval. However, it is more complex and feature-rich compared to the lightweight and focused github-username package.
github-username
Get a GitHub username from an email address
Install
$ npm install github-username
Usage
const githubUsername = require('github-username');
(async () => {
console.log(await githubUsername('sindresorhus@gmail.com'));
})();
API
githubUsername(email, token?)
Get the GitHub username from an email address if the email can be found in any commits on GitHub.
Returns a Promise<string?>
with the username.
email
Type: string
Email address for the user of whom you want the username.
token
Type: string
GitHub personal access token.
Related