
Public
Like
5
github-user-email
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.
Viewing readonly version of main branch: v172View latest version
It's an open secret that you can find the email address from most GitHub users:
it's in the git commit history! In the past, I would close repos and use
git log
to pull it out, but recently I learned that you can do it fairly
easily via the GitHub API.
This function pulls the user's recent public events.
import { emailFromEvents } from "https://esm.town/v/stevekrouse/github-user-email/events.ts";
const emails = await emailFromEvents("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.
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,