LoginSignup
1
1

More than 1 year has passed since last update.

Twitter API v2で引用ツイートを検索するときのクエリ

Last updated at Posted at 2022-02-06

GET /2/tweets/search/recent のクエリの作り方のTipsです。APIのアクセス方法などは書いていません。

自分への引用ツイートを検索したい

公式 クエリの作り方
https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query

引用リツイートのみを検索する場合、個別の引用元ツイートIDを入れれば簡単に検索は出来ますが、アカウントごとの引用ツイートを集めるのは少し工夫が必要です。

結論、これをクエリに入れれば想定通り集められます。

url:"https://twitter.com/{username}/" is:quote

url: を使うのがコツです。また、 is:quote を付けない場合、リツイートも引っかかってくるので意図しない結果が多くなります。

やりがちだがダメな例

引用ツイートは結局本文の末尾に引用元ツイートのURL( https://twitter.com/{username}/status/{id} )が含まれているので、それで検索できそうな気もしますが、url:オペレータを付けないと検索にかかりません。

▼これらだと引用ツイートは引っかからない( is:quote の有無は関係なく)

"https://twitter.com/{username}/" is:quote
"https://twitter.com/{username}/status/" is:quote
"https://twitter.com/{username}/status/{id}" is:quote
"{username}/status" is:quote
  などなど

一方で、はじめにも書きましたが、個別ツイートの引用RTを検索したい場合はIDでもOK

▼これはOK

{id} is:quote

また、url: is:quote などのオペレータはTwitter Webの検索窓とは少しだけ違うようなので、Web上からは使えません。

Webからの検索ではこのTweetDeck向けの説明書が役に立ちそうです。
https://help.twitter.com/ja/using-twitter/advanced-tweetdeck-features

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1