🚨🚨 With Twitter’s February 9, 2023 retirement of the free version of the API, this package is now archived/deprecated/retired. 🚨🚨
Find one or more twitter avatar image URLs from one or more twitter usernames.
- Automatically removes duplicate usernames from the input
- Handles Twitter API limits for you. This service limits 100 usernames per request but if you pass 200 unique usernames to this function, we will return 200 entries to you.
- This API is rate limited to 300 requests in a 15 minute window. Each 100-max limited call counts as one request.
npm install twitter-avatar-url
Available on npm.
Can use either the v1 or v2 Twitter API. Both require an .env
file with a TWITTER_BEARER_TOKEN
set. You can generate one of these from the Twitter Developer portal by creating an application.
const getTwitterAvatarUrl = require("twitter-avatar-url");
(async function() {
let avatars = await getTwitterAvatarUrl("zachleat"); // accepts string or array of strings
/*
// Returns an object like:
[
{ username: 'jamstackconf',
url:{
small: 'https://pbs.twimg.com/profile_images/1217872345651609603/-Ybv2ifT_normal.jpg',
large: 'https://pbs.twimg.com/profile_images/1217872345651609603/-Ybv2ifT_400x400.jpg'
}
}
]
*/
console.log( avatars[0].url.large );
})();
const getTwitterAvatarUrl = require("twitter-avatar-url");
let avatars = await getTwitterAvatarUrl("zachleat", {
twitterApiVersion: 1
});
// Returns the same object as the v2 API above.