2024-08-07 02:19:51 +00:00
---
title: Twitter
description: Official Twitter / X API client.
---
2025-03-24 15:21:59 +00:00
Basic Twitter API methods for fetching users, tweets, and searching recent tweets. Includes support for plan-aware rate-limiting.
2024-08-07 02:19:51 +00:00
- package: `@agentic/twitter`
- exports: `class TwitterClient`, `namespace twitter`
- env vars: `TWITTER_API_KEY`, `TWITTER_API_PLAN`
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/twitter/src/twitter-client.ts)
2025-03-24 15:21:59 +00:00
- [twitter api docs](https://docs.x.com/x-api)
2024-08-07 02:19:51 +00:00
## Install
<CodeGroup>
```bash npm
npm install @agentic/twitter
```
```bash yarn
yarn add @agentic/twitter
```
```bash pnpm
pnpm add @agentic/twitter
```
</CodeGroup>
## Usage
```ts
import { TwitterClient } from '@agentic/twitter'
const twitter = new TwitterClient()
const res = await twitter.createTweet({
text: 'hello, world'
})
```
2025-03-24 15:21:59 +00:00
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.