Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
twitter-api-suite
Advanced tools
Twitter API client for Node.js.
This library provides convenient access to the Twitter API from applications written in Node.js. It only supports the REST API at this moment. Support for Streaming, Enterprise and Ads APIs will be added soon.
Read the official Twitter documentation to learn more about API endpoints.
npm install twitter-api-suite --save
The package needs to be configured with OAuth tokens. You need a Twitter developer account to create apps and generate tokens. Apply here if you don't have one yet.
const Twitter = require('twitter-api-suite');
const twitter = new Twitter({
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token: process.env.ACCESS_TOKEN,
access_token_secret: process.env.ACCESS_TOKEN_SECRET
});
Or, when configuring the package with an application-only context:
const Twitter = require('twitter-api-suite');
const twitter = new Twitter({
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
app_only: true
});
twitter.get(endpoint, params, append_response)
Performs a GET request to the Twitter API.
twitter.post(endpoint, params, append_response)
Performs a POST request to the Twitter API.
twitter.put(endpoint, params, append_response)
Performs a PUT request to the Twitter API.
twitter.del(endpoint, params, append_response)
Performs a DELETE request to the Twitter API.
endpoint
API endpoint to call. For instance users/show
. List of all endpoints can be found here.
params (optional)
Parameters to pass to the request.
append_response (optional)
Boolean, defaults to false
. If set to true
, data returned in Promises has an additional _response
property corresponding to the raw HTTP response received from Twitter, including x-rate-limit-*
headers.
twitter.upload(params, append_response)
Implements the full logic (INIT, APPEND, FINALIZE, STATUS) of uploading media files through POST media/upload (chunked)
. The params
object must have media_path
which is the absolute path to the media file you want to upload. When uploading large files such as videos, the function returns when the media has been processed by Twitter (succeeded
or failed
).
const params = {
media_path: 'path/to/file.mp4'
}
Supported types and limits:
Every method returns a chainable Promise.
const Twitter = require('twitter-api-suite');
const twitter = new Twitter({
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token: process.env.ACCESS_TOKEN,
access_token_secret: process.env.ACCESS_TOKEN_SECRET
});
twitter.get('users/show', {
screen_name: 'b_lw'
}).then((user) => {
return twitter.post('friendships/create', {
user_id: user.id_str
});
}).then(() => {
return twitter.upload({
media_path: 'video.mp4'
});
}).then((media_data) => {
return twitter.post('statuses/update', {
status: 'Hello world',
media_ids: media_data.media_id_string
});
}).then((tweet_data) => {
console.log('Tweet ID', tweet_data.id_str);
}).catch((err) => {
console.log(err);
});
Contributions for new features, enhancements and bug fixes are welcome. When contributing to this repository, please first discuss the change you wish to make via issue or email before you submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
See also the list of contributors who participated in this project.
FAQs
Twitter API client for Node.js
We found that twitter-api-suite demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.