# twitter-avatar-url

> Find a twitter avatar image url from a twitter username.

Latest version **2.2.0** (published 2022-02-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install twitter-avatar-url
pnpm add twitter-avatar-url
yarn add twitter-avatar-url
bun add twitter-avatar-url
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2022-02-25 |
| First published | 2020-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zach Leatherman |
| Maintainers | zachleat |

## Links

- npm: https://www.npmjs.com/package/twitter-avatar-url
- npm.io page: https://npm.io/package/twitter-avatar-url

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [@11ty/eleventy-fetch](https://npm.io/package/@11ty/eleventy-fetch.md) ^3.0.0

## Recent versions

- 2.2.0 (latest) — 2022-02-25
- 2.1.0 — 2021-05-25
- 2.0.3 — 2020-12-22
- 2.0.2 — 2020-12-22
- 2.0.1 — 2020-12-22
- 2.0.0 — 2020-12-22
- 1.0.2 — 2020-06-24
- 1.0.1 — 2020-06-24
- 1.0.0 — 2020-06-24

## README

# twitter-avatar-url

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.

## Installation

```
npm install twitter-avatar-url
```

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](https://developer.twitter.com/) by creating an application.

* [Twitter API v2 `/users/lookup/by`](https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by) (default)
* [Twitter API v1 `/users/lookup`](https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup)

## Usage

```js
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 );
})();
```

### Use the Twitter v1 API

```js
const getTwitterAvatarUrl = require("twitter-avatar-url");

let avatars = await getTwitterAvatarUrl("zachleat", {
	twitterApiVersion: 1
});

// Returns the same object as the v2 API above.
```

---
_Source: https://npm.io/package/twitter-avatar-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
