A simple utility to help you extract your Twitter (X) cookies in JSON format, making it easy to use with libraries like agent-twitter-client or @the-convocation/twitter-scraper.
Many Twitter API alternatives require your browser cookies to authenticate requests. This tool simplifies the process of extracting those cookies in the correct format.
npm install -g twitter-cookietwitter-cookie <username> <password>Or simply without installation:
npx twitter-cookie <username> <password>Your cookies will be printed to the console as JSON array. You can then use it to initialize the Scraper class from agent-twitter-client or @the-convocation/twitter-scraper.
import { Scraper } from "agent-twitter-client";
const scraper = new Scraper();
await scraper.setCookies(cookies);
// use scraper to do something...Keep your cookie file secure and never share it. These cookies provide full access to your Twitter account.
MIT License