Tools
Official Twitter / X API client.
Basic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting.
- package:
@agentic/twitter
- exports:
class TwitterClient
,namespace twitter
- env vars:
TWITTER_API_KEY
,TWITTER_API_PLAN
- source
- twitter api docs
Install
Usage
This example uses Nango for OAuth support via the createTwitterV2Client helper function, but you can pass any instance of the underlying TwitterV2Client to the TwitterClient
constructor.
All TwitterClient
methods are automatically throttled based on your Twitter API plan. You can set the twitter plan by setting the TWITTER_API_PLAN
environment variable or by passing the twitterApiPlan
parameter to the TwitterClient
constructor.
This twitter client is pretty robust, taking into account my learnings from building a Twitter bot which gained over 150k followers.