{"id":15038869,"url":"https://github.com/plhery/node-twitter-api-v2","last_synced_at":"2025-05-14T04:07:44.458Z","repository":{"id":37273327,"uuid":"294221842","full_name":"PLhery/node-twitter-api-v2","owner":"PLhery","description":"Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.","archived":false,"fork":false,"pushed_at":"2025-05-12T19:18:38.000Z","size":4563,"stargazers_count":1447,"open_issues_count":64,"forks_count":210,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-12T20:30:19.485Z","etag":null,"topics":["npm-package","streaming-api","twitter-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/twitter-api-v2","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PLhery.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-09-09T20:26:35.000Z","updated_at":"2025-05-12T19:18:14.000Z","dependencies_parsed_at":"2024-01-06T13:09:03.229Z","dependency_job_id":"7d7527ae-b829-4a72-9fed-db57b1bba6c0","html_url":"https://github.com/PLhery/node-twitter-api-v2","commit_stats":{"total_commits":396,"total_committers":52,"mean_commits":7.615384615384615,"dds":"0.36363636363636365","last_synced_commit":"6016f37704c249e67a14f89e0c66db15a53b50bf"},"previous_names":[],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLhery%2Fnode-twitter-api-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLhery%2Fnode-twitter-api-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLhery%2Fnode-twitter-api-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PLhery%2Fnode-twitter-api-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PLhery","download_url":"https://codeload.github.com/PLhery/node-twitter-api-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253817652,"owners_count":21969018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-package","streaming-api","twitter-api"],"created_at":"2024-09-24T20:40:35.426Z","updated_at":"2025-05-14T04:07:44.424Z","avatar_url":"https://github.com/PLhery.png","language":"TypeScript","readme":"# Twitter API v2\n\n[![Version badge](https://badgen.net/github/release/PLhery/node-twitter-api-v2)](https://github.com/PLhery/node-twitter-api-v2)\n[![Checks badge](https://github.com/PLhery/node-twitter-api-v2/actions/workflows/CI.yml/badge.svg)](https://github.com/PLhery/node-twitter-api-v2/actions/workflows/CI.yml)\n[![Package size badge](https://badgen.net/bundlephobia/minzip/twitter-api-v2)](https://bundlephobia.com/package/twitter-api-v2)\n\nStrongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.\n\nMain maintainer: [@alkihis](https://github.com/alkihis) - \u003ca href=\"https://www.buymeacoffee.com/alkihis\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" height=\"20px\" marginTop=\"10px\"\u003e\u003c/a\u003e\n\n## Important Note\n\nTwitter will significantly reduce its API capabilities by end of April ([see this thread](https://x.com/TwitterDev/status/1641222782594990080)).\n\nThis change has major implications, and as a result, this library may no longer be maintained.\n\nWe are disappointed and discouraged by the recent turn of events at Twitter since the takeover by Elon Musk. We are saddened to see that much of the hard work of the past few years on the API, led by an amazing team including @andypiper, has been shelved.\n\nFor a more detailed explanation, please see [this discussion](https://github.com/PLhery/node-twitter-api-v2/discussions/459).\n\n## Highlights\n\n✅ **Ready for v2 and good ol' v1.1 Twitter API**\n\n✅ **Light: No dependencies, 23kb minified+gzipped**\n\n✅ **Bundled types for request parameters and responses**\n\n✅ **Streaming support**\n\n✅ **Pagination utils**\n\n✅ **User-context authentication with OAuth2**\n\n✅ **Media upload helpers**\n\n## How to use\n\nInstall it through your favorite package manager:\n```bash\nyarn add twitter-api-v2\n# or\nnpm i twitter-api-v2\n```\n\nHere's a quick example of usage:\n\n```ts\nimport { TwitterApi } from 'twitter-api-v2';\n\n// Instantiate with desired auth type (here's Bearer v2 auth)\nconst twitterClient = new TwitterApi('\u003cYOUR_APP_USER_TOKEN\u003e');\n\n// Tell typescript it's a readonly app\nconst readOnlyClient = twitterClient.readOnly;\n\n// Play with the built in methods\nconst user = await readOnlyClient.v2.userByUsername('plhery');\nawait twitterClient.v2.tweet('Hello, this is a test.');\n// You can upload media easily!\nawait twitterClient.v1.uploadMedia('./big-buck-bunny.mp4');\n```\n\n## Why?\n\nSometimes, you just want to quickly bootstrap an application using the Twitter API.\nEven though there are a lot of libraries available on the JavaScript ecosystem, they usually just\nprovide wrappers around HTTP methods, and some of them are bloated with many dependencies.\n\n`twitter-api-v2` is meant to provide full endpoint wrapping, from method name to response data,\nusing descriptive typings for read/write/DMs rights, request parameters and response payload.\n\nA small feature comparison with other libs:\n\n| Package        | API version(s)      | Response typings | Media helpers | Pagination | Subdeps |  Size (gzip)  | Install size  |\n| -------------- |---------------------| ---------------- | ------------- | ---------- | --------------- | -------------:|  -------------:|\n| twitter-api-v2 | v1.1, v2, labs, ads | ✅               | ✅             | ✅         | 0               | ~23 kB      | [![twitter-api-v2 install size badge](https://badgen.net/packagephobia/install/twitter-api-v2)](https://packagephobia.com/result?p=twitter-api-v2) |\n| twit           | v1.1                | ❌               | ✅             | ❌         | 51              | ~214.5 kB     | [![twit install size badge](https://badgen.net/packagephobia/install/twit)](https://packagephobia.com/result?p=twit) |\n| twitter        | v1.1                | ❌               | ❌             | ❌         | 50              | ~182.1 kB     | [![twitter install size badge](https://badgen.net/packagephobia/install/twitter)](https://packagephobia.com/result?p=twitter) |\n| twitter-lite   | v1.1, v2            | ❌               | ❌             | ❌         | 4               | ~5.3 kB       | [![twitter-lite install size badge](https://badgen.net/packagephobia/install/twitter-lite)](https://packagephobia.com/result?p=twitter-lite) |\n| twitter-v2     | v2                  | ❌               | ❌             | ❌         | 7               | ~4.5 kB       | [![twitter-v2 install size badge](https://badgen.net/packagephobia/install/twitter-v2)](https://packagephobia.com/result?p=twitter-v2) |\n\n## Features\n\nHere's everything `twitter-api-v2` can do:\n\n### Basics:\n- Support for v1.1 and **v2 of Twitter API**\n- Make signed HTTP requests to Twitter with every auth type: **OAuth 1.0a**, **OAuth2** (even brand new user context OAuth2!) and **Basic** HTTP Authorization\n- Helpers for numerous HTTP request methods (`GET`, `POST`, `PUT`, `DELETE` and `PATCH`),\n  that handle query string parse \u0026 format, automatic body formatting and more\n- High-class support for stream endpoints, with easy data consumption and auto-reconnect on stream errors\n\n### Request helpers:\n- Automatic paginator for endpoints like user and tweet timelines,\n  allowing payload consumption with modern asynchronous iterators until your rate-limit is hit\n- Convenient methods for authentication - generate auth links and ask for tokens to your users\n- Media upload with API v1.1, including **long video \u0026 subtitles support**, automatic media type detection,\n  **chunked upload** and support for **concurrent uploads**\n- Dedicated methods that wraps API v1.1 \u0026 v2 endpoints, with **typed arguments** and fully **typed responses**\n- Typed errors, meaningful error messages, error enumerations for both v1.1 and v2\n\n### Type-safe first:\n- **Typings for tweet, user, media entities (and more) are bundled!**\n- Type-safe wrapping of dedicated methods in 3 right level: *DM*/*Read-write*/*Read-only* (just like Twitter API do!) -\n  you can declare a read-only client - you will only see the methods associated with read-only endpoints\n\nAnd last but not least, fully powered by native `Promise`s.\n\n## Documentation\n\nLearn how to use the full potential of `twitter-api-v2`.\n\n- Get started\n  - [Create a client and make your first request](./doc/basics.md)\n  - [Handle Twitter authentication flows](./doc/auth.md)\n  - [Explore some examples](./doc/examples.md)\n  - [Use and create plugins](./doc/plugins.md)\n- Use endpoints wrappers — ensure typings of request \u0026 response\n  - [Available endpoint wrappers for v1.1 API](./doc/v1.md)\n  - [Available endpoint wrappers for v2 API](./doc/v2.md)\n  - [Use Twitter streaming endpoints (v1.1 \u0026 v2)](./doc/streaming.md)\n- Deep diving into requests\n  - [Use direct HTTP-method wrappers](./doc/http-wrappers.md)\n  - [Use rate limit helpers](./doc/rate-limiting.md)\n  - [Handle errors](./doc/errors.md)\n  - [Master `twitter-api-v2` paginators](./doc/paginators.md)\n  - [Discover available helpers](./doc/helpers.md)\n\n## Plugins\n\nOfficial plugins for `twitter-api-v2`:\n- [`@twitter-api-v2/plugin-token-refresher`](https://www.npmjs.com/package/@twitter-api-v2/plugin-token-refresher): Handle OAuth 2.0 (user-context) token refreshing for you\n- [`@twitter-api-v2/plugin-rate-limit`](https://www.npmjs.com/package/@twitter-api-v2/plugin-rate-limit): Access and store automatically rate limit data\n- [`@twitter-api-v2/plugin-cache-redis`](https://www.npmjs.com/package/@twitter-api-v2/plugin-cache-redis): Store responses in a Redis store and serve cached responses\n\nSee [how to use plugins here](./doc/plugins.md).\n","funding_links":["https://www.buymeacoffee.com/alkihis"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplhery%2Fnode-twitter-api-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplhery%2Fnode-twitter-api-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplhery%2Fnode-twitter-api-v2/lists"}