From 4c1f6d58399aef88b3e97ee19a958b9628abcc5b Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 24 Mar 2025 23:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/docs/tools/twitter.mdx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/legacy/docs/tools/twitter.mdx b/legacy/docs/tools/twitter.mdx index 1b325060..c1427051 100644 --- a/legacy/docs/tools/twitter.mdx +++ b/legacy/docs/tools/twitter.mdx @@ -31,12 +31,19 @@ pnpm add @agentic/twitter ## Usage ```ts -import { TwitterClient } from '@agentic/twitter' +import { TwitterClient, createTwitterV2Client } from '@agentic/twitter' -const twitter = new TwitterClient() +// Requires Nango connection ID and callback URL environment variables +const rawClient = await createTwitterV2Client() + +const twitter = new TwitterClient({ client: rawClient }) const res = await twitter.createTweet({ text: 'hello, world' }) ``` -Our examples use [Nango](https://www.nango.dev) for OAuth support via the `createTwitterV2Client` helper function, but you can pass any instance of the underlying [TwitterV2Client](https://github.com/twitterdev/twitter-api-typescript-sdk) to the `TwitterClient` constructor. +This example uses [Nango](https://www.nango.dev) for OAuth support via the [createTwitterV2Client](https://github.com/transitive-bullshit/agentic/blob/main/packages/twitter/src/client.ts#L53) helper function, but you can pass any instance of the underlying [TwitterV2Client](https://github.com/twitterdev/twitter-api-typescript-sdk) to the `TwitterClient` constructor. + +All `TwitterClient` methods are automatically throttled based on your [Twitter API plan](https://docs.x.com/x-api/fundamentals/rate-limits). 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](https://transitivebullsh.it/chatgpt-twitter-bot-lessons).