A command-line tool to fetch unique user IDs by username from Twitter (X), Discord, and Google/Gmail.
- Fetch Twitter/X user IDs using Twitter API v2
- Support for batch processing via JSON user list
- JSON output with detailed error messages
- Configurable via config file or environment variables
- ✅ Works: Can fetch user IDs by username using Bearer Token
- Requires Twitter API v2 access and Bearer Token
- Rate limits apply based on your API tier
- ❌ Limited: Discord API doesn't support global user lookup by username
- User IDs can only be retrieved if your bot shares a server with the user
- Recommended: Use Discord client with Developer Mode to manually copy user IDs
- ❌ Limited: Google APIs don't support arbitrary email-to-user-ID lookup
- Can only get info about the currently authenticated user
- For organization-wide lookups, use Google Workspace Admin SDK Directory API
- Go to Twitter Developer Portal
- Create a new project and app
- Generate a Bearer Token
- Copy the Bearer Token
- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section and create a bot
- Copy the bot token
- Go to Google Cloud Console
- Create a new project
- Enable People API or Gmail API
- Create OAuth 2.0 credentials
- Get an access token via OAuth flow
Create a config.json file:
{
"twitter_bearer_token": "YOUR_TWITTER_BEARER_TOKEN",
"discord_bot_token": "YOUR_DISCORD_BOT_TOKEN",
"google_access_token": "YOUR_GOOGLE_ACCESS_TOKEN"
}Or set environment variables:
export TWITTER_BEARER_TOKEN="your_token"
export DISCORD_BOT_TOKEN="your_token"
export GOOGLE_ACCESS_TOKEN="your_token"Create a userlist.json file:
[
{
"platform": "twitter",
"username": "elonmusk"
},
{
"platform": "twitter",
"username": "@jack"
}
]# Build the project
cargo build --release
# Run the tool
cargo run --release userlist.json
# Or use the binary directly
./target/release/user-id-fetcher userlist.jsonThe tool outputs results in JSON format and saves them to results.json:
[
{
"platform": "twitter",
"username": "elonmusk",
"user_id": "44196397",
"error": null
},
{
"platform": "discord",
"username": "someuser#1234",
"user_id": null,
"error": "Discord API doesn't support global user lookup by username..."
}
]This project is licensed under the Apache 2.0 License.
-
Build the project:
cargo build --release
-
Set up your credentials in
config.jsonor environment variables -
Create your user list in
userlist.json -
Run the tool:
cargo run --release userlist.json
The tool will:
- Load the configuration and user list
- Fetch user IDs for each entry (where supported)
- Display progress with logging
- Output results as JSON
- Save results to
results.json
Note: Due to API limitations, only Twitter/X fully supports username-to-ID lookup. Discord and Google have significant restrictions that make programmatic lookup challenging or impossible without special access.