AI Personal Learning
and practical guidance
Resource Recommendation 1

agent-twitter-client: send and retweet tweets without Twitter API key

General Introduction

agent-twitter-client is a Twitter client that works without a Twitter API key. The project is based on @the-convocation/twitter-scraper modified to add the ability to send tweets and retweets. It runs on both browsers and servers and is suitable for users who need to automate Twitter operations. By configuring environment variables for authentication, users can easily send tweets, get tweets and perform other Twitter operations.

agent-twitter-client: send, retweet tweets without Twitter API key-1


 

Function List

  • Send tweets and retweets
  • Get tweets from specific users
  • Get tweets and their replies
  • Get the latest tweets
  • Tweets and Polling Functionality with Twitter API v2
  • Support for proxy requests
  • Get Twitter Cookies to Avoid Frequent Logins

 

Using Help

Installation process

  1. Cloning Project Warehouse:
   git clone https://github.com/elizaOS/agent-twitter-client.git
  1. Go to the project catalog:
   cd agent-twitter-client
  1. Install the dependencies:
   npm install

Configuring Environment Variables

In the project root directory, create a.envfile and add the following:

TWITTER_USERNAME=your Twitter username
TWITTER_PASSWORD=Your Twitter password.
TWITTER_EMAIL=your Twitter email address
PROXY_URL=Your proxy URL (if needed)
TWITTER_API_KEY=your Twitter API key
TWITTER_API_SECRET_KEY=your Twitter API key
TWITTER_ACCESS_TOKEN=your Twitter access token
TWITTER_ACCESS_TOKEN_SECRET=your Twitter access token key

usage example

Get Tweets

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('Your username', 'Your password');
const tweets = await scraper.getTweets('elonmusk', 10);
console.log(tweets);
})();

Send a tweet

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('your username', 'your password'); await scraper.sendTweet('Hello world'); const scraper = new scraper() => {
await scraper.sendTweet('Hello world!');
})();

Get the latest tweets

const { Scraper } = require('agent-twitter-client');
const scraper = new Scraper();
(async () => {
await scraper.login('your username', 'your password');
const latestTweet = await scraper.getLatestTweet('elonmusk');

})();

Detailed Functions

  1. Send tweets and retweets: Users can be authenticated by configuring environment variables and then using thesendTweetmethod to send a tweet, or use thesendRetweetmethod for retweeting.
  2. Get Tweets: UsegetTweetsmethod to get tweets from a specific user.getTweetsAndRepliesmethod to get tweets and their replies.
  3. Get the latest tweets: UsegetLatestTweetmethod to get the latest tweets from a specific user.
  4. Using the Twitter API v2: By configuring keys and tokens for Twitter API v2, users can use thesendTweetV2method to send tweets with polling functionality.
  5. proxy request: Supports the configuration of thePROXY_URLenvironment variable to use the proxy for requests.
  6. Getting Twitter Cookies: UsegetCookiesmethod to get Twitter cookies to avoid frequent logins.
Content 2
May not be reproduced without permission:Chief AI Sharing Circle " agent-twitter-client: send and retweet tweets without Twitter API key

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish