
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
twitter-api-v2
Advanced tools
Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
Main maintainer: @alkihis -
Twitter will significantly reduce its API capabilities by end of April (see this thread).
This change has major implications, and as a result, this library may no longer be maintained.
We 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.
For a more detailed explanation, please see this discussion.
ā Ready for v2 and good ol' v1.1 Twitter API
ā Light: No dependencies, 23kb minified+gzipped
ā Bundled types for request parameters and responses
ā Streaming support
ā Pagination utils
ā User-context authentication with OAuth2
ā Media upload helpers
Install it through your favorite package manager:
yarn add twitter-api-v2
# or
npm i twitter-api-v2
Here's a quick example of usage:
import { TwitterApi } from 'twitter-api-v2';
// Instantiate with desired auth type (here's Bearer v2 auth)
const twitterClient = new TwitterApi('<YOUR_APP_USER_TOKEN>');
// Tell typescript it's a readonly app
const readOnlyClient = twitterClient.readOnly;
// Play with the built in methods
const user = await readOnlyClient.v2.userByUsername('plhery');
await twitterClient.v2.tweet('Hello, this is a test.');
// You can upload media easily!
await twitterClient.v1.uploadMedia('./big-buck-bunny.mp4');
Sometimes, you just want to quickly bootstrap an application using the Twitter API. Even though there are a lot of libraries available on the JavaScript ecosystem, they usually just provide wrappers around HTTP methods, and some of them are bloated with many dependencies.
twitter-api-v2
is meant to provide full endpoint wrapping, from method name to response data,
using descriptive typings for read/write/DMs rights, request parameters and response payload.
A small feature comparison with other libs:
Here's everything twitter-api-v2
can do:
GET
, POST
, PUT
, DELETE
and PATCH
),
that handle query string parse & format, automatic body formatting and moreAnd last but not least, fully powered by native Promise
s.
Learn how to use the full potential of twitter-api-v2
.
Official plugins for twitter-api-v2
:
@twitter-api-v2/plugin-token-refresher
: Handle OAuth 2.0 (user-context) token refreshing for you@twitter-api-v2/plugin-rate-limit
: Access and store automatically rate limit data@twitter-api-v2/plugin-cache-redis
: Store responses in a Redis store and serve cached responsesFAQs
Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.
The npm package twitter-api-v2 receives a total of 79,486 weekly downloads. As such, twitter-api-v2 popularity was classified as popular.
We found that twitter-api-v2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.