2025-09-16 16:49:54 +09:00

76 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## X
### 公式API
* ポストの投稿
* 自社のサービスからXに投稿できる
* ポストの取得、検索
* 特定のキーワードやハッシュタグを含むポストを検索できる
無料プランの制限
| プラン | FREE |
| ------------ | ---------- |
| ポスト投稿 | 1,500件/月 |
| 月間投稿取得 | |
| | |
**手順**
* https://qiita.com/dl_from_scratch/items/75d3bb60fc2a93da9917
* https://qiita.com/neru-dev/items/857cc27fd69411496388
* https://zenn.dev/masuda1112/articles/2024-10-26-craete-post-by-python
* アカウントからAPIキーを発行する
* https://developer.twitter.com/ja
* APIの利用目的の記載が必要
* APIKEYを取得する
* User authentication settingsで権限を設定する
* Read(デフォルト) -> Read and write
sample
```txt
I plan to use the X API to collect and analyze public conversations (tweets and replies) related to AI, technology, and news.
The purpose is non-commercial research and educational use, such as understanding discussion trends and generating summary reports.
Data will not be shared with third parties and will only be stored temporarily for analysis.
All usage will comply with Xs Developer Policy and data protection requirements.
私は X API を利用して、AI、テクロジー、ニュースに関連する公開の会話ツイートやリプライを収集・分析する予定です。
目的は、議論の動向を理解したり要約レポートを作成したりするなど、非営利の研究や教育利用です。
データは分析のために一時的に保存するだけで、第三者と共有することはありません。
すべての利用は X の開発者ポリシーとデータ保護要件に従います。
```
#### 取得フィールドについて
**tweet.fields**
* created_at ツイートの投稿日時 (UTC, ISO8601形式)
* author_id 投稿者ユーザーの ID (数値文字列)
* conversation_id 会話スレッドを一意に識別する ID
同じ会話に属する全ツイートで同じIDになる
* public_metrics インタラクション数
retweet_count, reply_count, like_count, quote_count など)
* referenced_tweets このツイートが返信・引用リツイート・リツイートかどうかを示す情報
**expansions**
IDだけではなく関連オブジェクトユーザーやメディアなど
「展開」して返す指定。
* author_id (author_id を展開)
* ユーザー情報を includes.users に含めて返す。
**user.fields**
ユーザーオブジェクトに欲しい追加情報を指定。
* username @なしのスクリーンネーム (例: jack)
* name 表示名 (例: Jack Dorsey)
* verified 認証済みアカウントかどうかTrue/False
### スクレイピング