# get-twitter-media

> Get media from tweets quick and easy.

Latest version **2.0.8** (published 2024-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-twitter-media
pnpm add get-twitter-media
yarn add get-twitter-media
bun add get-twitter-media
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.8 |
| Published | 2024-01-10 |
| First published | 2022-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Xeukxz |
| Maintainers | xeukxz |
| Keywords | twitter, tweet, media, link, get, buffer, video, stream, twit, scrape, picture, photo, href, url, image, download, downloader, X, elon |

## Links

- npm: https://www.npmjs.com/package/get-twitter-media
- Repository: https://github.com/Xeukxz/get-twitter-media
- Homepage: https://github.com/Xeukxz/get-twitter-media#readme
- Issues: https://github.com/Xeukxz/get-twitter-media/issues
- npm.io page: https://npm.io/package/get-twitter-media

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.1.2
- [ts-node](https://npm.io/package/ts-node.md) ^10.9.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.0.8 (latest) — 2024-01-10
- 2.0.7 — 2023-09-04
- 2.0.6 — 2023-08-09
- 2.0.5 — 2023-08-06
- 2.0.4 — 2023-08-06
- 2.0.3 — 2023-08-06
- 2.0.2 — 2023-08-06
- 2.0.1 — 2023-08-06
- 2.0.0 — 2023-08-06
- 1.0.2 — 2022-10-12
- 1.0.1 — 2022-10-12
- 1.0.0 — 2022-10-12

## README

# Installation:
```
> npm i get-twitter-media
```

# Usage:

`Params:`
- __url__ - | `type: string | MediaOptionsWithUrl` | - A URL or an object with a URL property, and optionally a buffer and/or text property
- __options__ - | `type: MediaOptions` | - An object with a buffer and/or text property

```js
const getTwitterMedia = require('get-twitter-media');
getTwitterMedia(url, options)
```

# Examples:

`Example with buffer:`
```js
const getTwitterMedia = require('get-twitter-media');
let media = await getTwitterMedia("https://twitter.com/CursedVideos/status/1687071264848879616?s=20", {
                    buffer: true
                  });
console.log(media);
```

`Output with buffer:`
```js
{
  found: true,
  type: 'Video',
  media: {
    url: 'https://video.twimg.com/amplify_video/1687071206959177728/vid/854x480/SlOcOcqfwdfNhtdk.mp4?tag=14',
    buffer: <Buffer 00 00 00 1c 66 74 79 70 6d 70  ... 3522918 more bytes> 
  }
}
```


`Example with text:`
```js
const getTwitterMedia = require('get-twitter-media');
let media = await getTwitterMedia("https://twitter.com/TurnkeyPet/status/1523047586998865920", {
                    text: true,
            });
console.log(media);
```

`Output with text:`
```js
{
  found: true,
  type: 'image',
  media: {
    url: 'https://pbs.twimg.com/media/FSLztSMVcAA84nP.jpg'
  },
  text: "My little rescue dog..Iris who is blind now due to cruel treatment, we have had her a year now had one eye taken out and lots of other things done and she's now a little monkey!! https://t.co/BKqd0ruHzc"
}
```

# Types (d.ts reference):
```ts
export interface MediaOptions {
    buffer?: boolean
    text?: boolean
}

export interface MediaOptionsWithUrl extends MediaOptions {
    url: string
}

export interface Output {
    found: true
    type: "video" | "image" | "gif"
    media: {
        url: string
        buffer?: Buffer
    }
    text?: string
}
export interface ErrorOutput {
    found: false
    error: string
}

export function getTwitterMedia(url: string | MediaOptionsWithUrl, options?: MediaOptions): Promise<Output>

```

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