FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
stevekrouse

stevekrouse

github-user-email

Get the email address for GitHub username
Public
Like
5
github-user-email
Home
Code
5
README.md
commits.ts
events.ts
examples.ts
index.ts
Branches
3
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
8/1/2025
Viewing readonly version of main branch: v235
View latest version
README.md

Get the email address for GitHub username

TypeScript function to get a GitHub user's email from their public event commit history via the GitHub API.

emailsFromGitHubUsername(username: string) (recommended)

This function first looks for the user's email in recent commits (last 30 days), and if not there, looks at commits in repos they own.

Create val
import { emailsFromGitHubUsername } from "https://esm.town/v/stevekrouse/github-user-email/index.ts"; // Recommended, combines both functions, only uses the more expensive one if the cheaper one fails const emails = await emailsFromGitHubUsername("stevekrouse"); console.log(emails); // [ "steveykrouse@gmail.com" ]

From email to github username

If you want to go in the reverse direction (from an email to a github username), check out sindresorhus/github-username.

Create val
import githubUsername from "npm:github-username"; console.log(await githubUsername("sindresorhus@gmail.com")); //=> 'sindresorhus'

Helper methods

emailsFromGitHubEvents(username: string)

This function pulls the user's recent public events.

Create val
import { emailsFromGitHubEvents } from "https://esm.town/v/stevekrouse/github-user-email/events.ts"; const emails = await emailsFromGitHubEvents("stevekrouse"); console.log(emails); // [ "steveykrouse@gmail.com" ]

The limitation is that this endpoint only gets events from the last 30 days, so if the user hasn't committed in the last month, you won't get any results from this method.

emailsFromGitHubCommits(username: string)

Pulls commits from repos that the username owns. Uses up your GitHub rate limit much faster.

Create val
import { emailsFromGitHubCommits } from "https://esm.town/v/stevekrouse/github-user-email/commits.ts"; const commitsEmails = await emailsFromGitHubCommits("stevekrouse"); console.log(commitsEmails); // [ "steveykrouse@gmail.com" ]

Rate limits

The GitHub API rate limits unauthenticated requests to 60 per hour per IP address. As a quick workaround, Val Town provides an IP-randomizer fetch proxy that makes it easy to get around these limits. These functions use that proxy by default. However, if you're using these functions at scale, please use a GITHUB_TOKEN to be a good GitHub citizen.

Get a Github Access Token

  1. Go to https://github.com/settings/personal-access-tokens/new
  2. Give it a name like Get user emails
  3. Set the expiration appropriately (I recommend No expiration)
  4. Click Generate token
  5. Copy the token into your val's env variables (in the left sidebar) as GITHUB_TOKEN
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.