{"_id":"@0xindie/agent-twitter-client","name":"@0xindie/agent-twitter-client","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0xindie/agent-twitter-client","description":"Fork of agent-twitter-client with latest feature","keywords":["x","twitter","scraper","crawler"],"version":"1.0.0","main":"dist/default/cjs/index.js","types":"./dist/types/index.d.ts","exports":{"types":"./dist/types/index.d.ts","node":{"import":"./dist/node/esm/index.mjs","require":"./dist/node/cjs/index.cjs"},"default":{"import":"./dist/default/esm/index.mjs","require":"./dist/default/cjs/index.js"}},"author":{"name":"0xindie"},"license":"MIT","scripts":{"build":"rimraf dist && rollup -c","docs:generate":"typedoc --options typedoc.json","docs:deploy":"npm run docs:generate && gh-pages -d docs","format":"prettier --write src/**/*.ts","test":"jest"},"dependencies":{"@sinclair/typebox":"^0.32.20","agent-twitter-client":"^0.0.13","headers-polyfill":"^3.1.2","json-stable-stringify":"^1.0.2","otpauth":"^9.2.2","set-cookie-parser":"^2.6.0","tough-cookie":"^4.1.2","tslib":"^2.5.2","twitter-api-v2":"^1.18.2"},"devDependencies":{"@commitlint/cli":"^17.6.3","@commitlint/config-conventional":"^17.6.3","@tsconfig/node16":"^16.1.3","@types/jest":"^29.5.1","@types/json-stable-stringify":"^1.0.34","@types/node":"^22.9.0","@types/set-cookie-parser":"^2.4.2","@types/tough-cookie":"^4.0.2","@typescript-eslint/eslint-plugin":"^5.59.7","@typescript-eslint/parser":"^5.59.7","dotenv":"^16.4.5","esbuild":"^0.21.5","eslint":"^8.41.0","eslint-config-prettier":"^8.8.0","eslint-plugin-prettier":"^4.2.1","gh-pages":"^5.0.0","https-proxy-agent":"^7.0.2","jest":"^29.7.0","lint-staged":"^13.2.2","prettier":"^2.8.8","rimraf":"^5.0.7","rollup":"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-esbuild":"^6.1.1","ts-jest":"^29.1.0","typedoc":"^0.24.7","typescript":"^5.0.4"},"lint-staged":{"*.{js,ts}":["eslint --cache --fix","prettier --write"]},"_id":"@0xindie/agent-twitter-client@1.0.0","gitHead":"7ba97d2c6747bc3c968aa1fd7fd750c44364e8df","_nodeVersion":"23.1.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-6ATQXaW0AzPVrvzajP588QlIp+CCsgvrpXPdIoxRzUX46yAj+sRli9swoWYHLrEAV4EQWur6EVfanwgTIBqjJg==","shasum":"b6de35d70cfced4aef89e34d1ea18e429e0d1ee6","tarball":"https://registry.npmjs.org/@0xindie/agent-twitter-client/-/agent-twitter-client-1.0.0.tgz","fileCount":59,"unpackedSize":1568094,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCPCiSqJh5Udc9NhAt/bg3MOWxOr6E8tRnLARkfGZT/uwIgSczWNRjW+CwOsdhNl8Dcr9yGOPGSK1sT857H+082p7E="}]},"_npmUser":{"name":"0xindiearc","email":"siennapill@proton.me"},"directories":{},"maintainers":[{"name":"0xindiearc","email":"siennapill@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/agent-twitter-client_1.0.0_1731776487070_0.8993123270267858"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-16T17:01:26.957Z","1.0.0":"2024-11-16T17:01:27.321Z","modified":"2024-11-16T17:01:27.582Z"},"maintainers":[{"name":"0xindiearc","email":"siennapill@proton.me"}],"description":"Fork of agent-twitter-client with latest feature","keywords":["x","twitter","scraper","crawler"],"author":{"name":"0xindie"},"license":"MIT","readme":"# agent-twitter-client\n\nThis is a modified version of [@the-convocation/twitter-scraper](https://github.com/the-convocation/twitter-scraper) with added functionality for sending tweets and retweets. This package does not require the Twitter API to use and will run in both the browser and server.\n\n## Installation\n\n```sh\nnpm install agent-twitter-client\n```\n\n## Setup\n\nConfigure environment variables for authentication.\n\n```\nTWITTER_USERNAME=    # Account username\nTWITTER_PASSWORD=    # Account password\nTWITTER_EMAIL=       # Account email\nPROXY_URL=           # HTTP(s) proxy for requests (necessary for browsers)\n\n# Twitter API v2 credentials for tweet and poll functionality\nTWITTER_API_KEY=               # Twitter API Key\nTWITTER_API_SECRET_KEY=        # Twitter API Secret Key\nTWITTER_ACCESS_TOKEN=          # Access Token for Twitter API v2\nTWITTER_ACCESS_TOKEN_SECRET=   # Access Token Secret for Twitter API v2\n```\n\n### Getting Twitter Cookies\n\nIt is important to use Twitter cookies to avoid sending a new login request to Twitter every time you want to perform an action.\n\nIn your application, you will likely want to check for existing cookies. If cookies are not available, log in with user authentication credentials and cache the cookies for future use.\n\n```ts\nconst scraper = await getScraper({ authMethod: 'password' });\n\nscraper.getCookies().then((cookies) => {\n  console.log(cookies);\n  // Remove 'Cookies' and save the cookies as a JSON array\n});\n```\n\n## Getting Started\n\n```ts\nconst scraper = new Scraper();\nawait scraper.login('username', 'password');\n\n// If using v2 functionality (currently required to support polls)\nawait scraper.login(\n  'username',\n  'password',\n  'email',\n  'appKey',\n  'appSecret',\n  'accessToken',\n  'accessSecret',\n);\n\nconst tweets = await scraper.getTweets('elonmusk', 10);\nconst tweetsAndReplies = scraper.getTweetsAndReplies('elonmusk');\nconst latestTweet = await scraper.getLatestTweet('elonmusk');\nconst tweet = await scraper.getTweet('1234567890123456789');\nawait scraper.sendTweet('Hello world!');\n\n// Create a poll\nawait scraper.sendTweetV2(\n  `What's got you most hyped? Let us know! 🤖💸`,\n  undefined,\n  {\n    poll: {\n      options: [\n        { label: 'AI Innovations 🤖' },\n        { label: 'Crypto Craze 💸' },\n        { label: 'Both! 🌌' },\n        { label: 'Neither for Me 😅' },\n      ],\n      durationMinutes: 120, // Duration of the poll in minutes\n    },\n  },\n);\n```\n\n### Fetching Specific Tweet Data (V2)\n\n```ts\n// Fetch a single tweet with poll details\nconst tweet = await scraper.getTweetV2('1856441982811529619', {\n  expansions: ['attachments.poll_ids'],\n  pollFields: ['options', 'end_datetime'],\n});\nconsole.log('tweet', tweet);\n\n// Fetch multiple tweets with poll and media details\nconst tweets = await scraper.getTweetsV2(\n  ['1856441982811529619', '1856429655215260130'],\n  {\n    expansions: ['attachments.poll_ids', 'attachments.media_keys'],\n    pollFields: ['options', 'end_datetime'],\n    mediaFields: ['url', 'preview_image_url'],\n  },\n);\nconsole.log('tweets', tweets);\n```\n\n## API\n\n### Authentication\n\n```ts\n// Log in\nawait scraper.login('username', 'password');\n\n// Log out\nawait scraper.logout();\n\n// Check if logged in\nconst isLoggedIn = await scraper.isLoggedIn();\n\n// Get current session cookies\nconst cookies = await scraper.getCookies();\n\n// Set current session cookies\nawait scraper.setCookies(cookies);\n\n// Clear current cookies\nawait scraper.clearCookies();\n```\n\n### Profile\n\n```ts\n// Get a user's profile\nconst profile = await scraper.getProfile('TwitterDev');\n\n// Get a user ID from their screen name\nconst userId = await scraper.getUserIdByScreenName('TwitterDev');\n```\n\n### Search\n\n```ts\nimport { SearchMode } from 'agent-twitter-client';\n\n// Search for recent tweets\nconst tweets = scraper.searchTweets('#nodejs', 20, SearchMode.Latest);\n\n// Search for profiles\nconst profiles = scraper.searchProfiles('John', 10);\n\n// Fetch a page of tweet results\nconst results = await scraper.fetchSearchTweets('#nodejs', 20, SearchMode.Top);\n\n// Fetch a page of profile results\nconst profileResults = await scraper.fetchSearchProfiles('John', 10);\n```\n\n### Relationships\n\n```ts\n// Get a user's followers\nconst followers = scraper.getFollowers('12345', 100);\n\n// Get who a user is following\nconst following = scraper.getFollowing('12345', 100);\n\n// Fetch a page of a user's followers\nconst followerResults = await scraper.fetchProfileFollowers('12345', 100);\n\n// Fetch a page of who a user is following\nconst followingResults = await scraper.fetchProfileFollowing('12345', 100);\n```\n\n### Trends\n\n```ts\n// Get current trends\nconst trends = await scraper.getTrends();\n\n// Fetch tweets from a list\nconst listTweets = await scraper.fetchListTweets('1234567890', 50);\n```\n\n### Tweets\n\n```ts\n// Get a user's tweets\nconst tweets = scraper.getTweets('TwitterDev');\n\n// Get a user's liked tweets\nconst likedTweets = scraper.getLikedTweets('TwitterDev');\n\n// Get a user's tweets and replies\nconst tweetsAndReplies = scraper.getTweetsAndReplies('TwitterDev');\n\n// Get tweets matching specific criteria\nconst timeline = scraper.getTweets('TwitterDev', 100);\nconst retweets = await scraper.getTweetsWhere(\n  timeline,\n  (tweet) => tweet.isRetweet,\n);\n\n// Get a user's latest tweet\nconst latestTweet = await scraper.getLatestTweet('TwitterDev');\n\n// Get a specific tweet by ID\nconst tweet = await scraper.getTweet('1234567890123456789');\n```\n","readmeFilename":"README.md"}