---
title: "Paperclip"
description: "Paperclip エージェント向け TwexAPI Paperclip プラグインをインストールし、ツイート検索、プロフィール、タイムライン、トレンドツイートを利用する。"
---

TwexAPI Paperclip プラグインは [Paperclip](https://paperclip.ai) エージェントに6つの読み取り専用 Twitter/X ツールを追加します。ドキュメント化された TwexAPI REST ルートを型付きツールスキーマ、シークレットバック認証、予測可能な JSON 結果でラップします。

Paperclip エージェントが生 HTTP 呼び出しなしでツイート検索、プロフィール参照、ユーザー検索、タイムライン読み取り、グローバルトレンドツイートを必要とする場合にこのプラグインを使用してください。

## ツール

| Agent task | Paperclip tool | TwexAPI route |
| --- | --- | --- |
| ツイート検索 | `twexapi.search_tweets` | `POST /twitter/advanced_search/page` |
| 1件のツイート読み取り | `twexapi.lookup_tweet` | `POST /v2/tweet/detail` |
| ユーザー検索 | `twexapi.search_users` | `GET /twitter/search-user/{keyword}/{target_count}` |
| プロフィール読み取り | `twexapi.get_user` | `GET /twitter/{screen_name}/about` |
| プロフィールツイート読み取り | `twexapi.get_user_tweets` | `POST /twitter/{screen_name}/timeline/page` |
| トレンドツイート読み取り | `twexapi.get_trends` | `GET /twitter/global-trending/tweets` |

このプラグインはフォロワーエクスポートや投稿公開は行いません。それらのタスクには [REST API](/api-reference/overview)、[CLI](/sdks/cli)、または [MCP Server](/mcp/overview) を使用してください。

## 前提条件

- Node.js 18 以降
- Paperclip CLI（`paperclipai`）
- [ダッシュボード](https://twexapi.io/dashboard) から取得した TwexAPI API キー
- API キー用の Paperclip シークレット参照

## インストール

```bash
paperclipai plugin install @twexapi-dev/paperclip-plugin-x-api-scraper
```

再現可能なインストールが必要な場合は現在のリリースをピン留めします。

```bash
paperclipai plugin install @twexapi-dev/paperclip-plugin-x-api-scraper --version 0.1.2
```

npm: [@twexapi-dev/paperclip-plugin-x-api-scraper](https://www.npmjs.com/package/@twexapi-dev/paperclip-plugin-x-api-scraper)

ソース: [twexapi-dev/paperclip-plugin-x-api-scraper](https://github.com/twexapi-dev/paperclip-plugin-x-api-scraper)

## 設定

[TwexAPI ダッシュボード](https://twexapi.io/dashboard) で API キーを作成します。Paperclip シークレットに保存し、プラグイン設定から参照します。

| 設定項目 | 用途 |
| --- | --- |
| `apiBaseUrl` | TwexAPI REST エンドポイント。デフォルト `https://api.twexapi.io`。 |
| `apiKeySecretRef` | TwexAPI API キー用 Paperclip シークレット参照。 |
| `defaultTimelineCount` | デフォルトタイムラインページ数（1〜100）。 |
| `defaultUserSearchCount` | デフォルトユーザー検索数（1〜100）。 |
| `defaultTrendCount` | デフォルトトレンド数（1〜100）。 |

Paperclip は呼び出し時に API キーを解決し、`Authorization: Bearer` を送信します。

プラグイン設定例:

```json
{
  "apiBaseUrl": "https://api.twexapi.io",
  "apiKeySecretRef": "twexapi/api-key",
  "defaultTimelineCount": 20,
  "defaultUserSearchCount": 10,
  "defaultTrendCount": 20
}
```

ソース管理にチェックインするプラグイン設定ファイルに API キーをコミットしないでください。

## エージェントタスク例

### ツイート検索

エージェントにトピックに関する最近の投稿を検索させます。プラグインは `twexapi.search_tweets` 経由で `POST /twitter/advanced_search/page` を呼び出します。

推奨プロンプト:

```text
Search X for recent posts about "AI agents lang:en -filter:retweets".
Return tweet IDs, author usernames, text, and created_at for the top 10 results.
```

### プロフィールとタイムラインの読み取り

```text
Look up @openai, then read the latest timeline page.
Return username, user_id, follower count, and the 5 most recent tweet IDs.
```

### グローバルトレンドツイートの読み取り

```text
Get trending tweets for United States, topic Sports, content NFL.
Summarize the top themes and list 5 representative tweet IDs.
```

## ハンドオフチェックリスト

Paperclip エージェントが結果を下流システムに渡す場合、安定識別子を保持してください。

| Data type | Store |
| --- | --- |
| ツイート | `tweet_id`, `text`, `author_username`, `created_at`, 検索クエリ |
| プロフィール | `user_id`, `username`, `name`, フォロワー数 |
| トレンド | 国、トピック、コンテンツタグ、ツイート行 |
| ページネーション | `next_cursor`, `has_more`, 元のリクエストパラメータ |

同一ワークフローで Paperclip ツールと MCP ベースエージェントを混在させる場合は [Agent MCP Handoff](/mcp/agent-handoff) を参照してください。

## エラー処理

| ステータス | 対処法 |
| ------ | ------ |
| `400` | ツール入力を修正。変更なしでリトライしない。 |
| `401` | Paperclip シークレット参照と API キー値を確認。 |
| `403` | アカウントアクセスとクレジットを確認。 |
| `429` | リトライ前にバックオフ。 |
| `5xx` | 上限付きバックオフでリトライ。 |

## ローカル開発

```bash
git clone https://github.com/twexapi-dev/paperclip-plugin-x-api-scraper.git
cd paperclip-plugin-x-api-scraper
pnpm install
pnpm check
```

`pnpm check` は型チェック、テスト、ビルドを実行します。

## 関連ガイド

* [MCP Server](/mcp/overview)
* [CLI](/sdks/cli)
* [TypeScript SDK](/sdks/typescript)
* [OpenAPI schema](https://docs.twexapi.io/openapi.json)
* [Source repository](https://github.com/twexapi-dev/paperclip-plugin-x-api-scraper)
