Package Exports
- twitter-v1-oauth
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (twitter-v1-oauth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Twitter API v1.1 OAuth 1.0a 🔑
Simple and minimalist module to send OAuth 1.0a requests to the Twitter API v1.1.
It returns an object with the request options necessary to make a request using your favorite tool.
import dotenv from "dotenv";
import oAuthV1Request from "twitter-v1-oauth";
import axios from "axios";
dotenv.config();
const oAuthOptions = {
api_key: process.env.TWITTER_API_KEY || "",
api_secret_key: process.env.TWITTER_API_SECRET_KEY || "",
access_token: process.env.TWITTER_ACCESS_TOKEN || "",
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET || "",
};
const baseURL = "https://api.twitter.com/1.1/search/tweets.json";
const method = "GET";
const params = { q: "twitter bot" };
const searchRequest = oAuthV1Request({
oAuthOptions,
method,
baseURL,
params,
});
axios
.request(searchRequest)
.then(({ data }) => console.log(data))
.catch((err) => {
if (err.response) {
return console.log(err.response);
}
console.log(err);
});No dependencies and super small: .

Install
npm install twitter-v1-oauthUsage
Create an app and get your credentials, you will need:
- API KEY
- API SECRET KEY
- ACCESS TOKEN
- ACCESS TOKEN SECRET
Use your preferred library to send the request using the documented endpoints and parameters for the twitter v1 API.
CommonJS
const authRequest = require("twitter-v1-oauth").default;ES6 Modules
import oAuthV1Request from "twitter-v1-oauth";TypeScript
Type definitions are included.
Examples
Check the examples directory for ideas on how to use it with axios.
The index.test.ts file should also provide a good idea on its usage.