FC2ブログ

Twitter APIのリクエスト制限数は、1時間当たり350回です。

2010/12/23現在の制限数です。

Twitter4JからAPIをガリガリテストしていたら、以下のエラーが帰ってきました。
400:The request was invalid. An accompanying error message will explain why. This is the status code will be returned during rate limiting.
error - Rate limit exceeded. Clients may not make more than 350 requests per hour.
整理すると、
350回 / 1時間
約6回 / 1分間

アプリ開発は大変ですな。

公式:Things Every Developer Should Know | dev.twitter.com
Anonymous calls are based on the IP of the host and are permitted 150 requests per hour. This classification includes unauthenticated requests (such as RSS feeds), and authenticated requests to resources that do not require authentication.
OAuth calls are permitted 350 requests per hour.
ふむふむ。Anonymous callsってなんだろうなぁ?


その後。
うーん。間隔あけても以下のエラーが返ってくる。
502:Twitter is down or being upgraded
Twitter の処理能力の限界を超えました。
しばらく経ってから、再度お試しください。詳細な情報については、Twitter ステータスもご確認ください。
2,3回リクエスト投げただけで、こんな状況。時間帯によるのかもしれません。
しっかり例外処理入れて開発しませんとな。


その後のその後。
カーソルを後ろにすればする程、エラーの頻度が上がってる。。
500:Something is broken. Please post to the group so the Twitter team can investigate.
技術的な不具合が発生しています。
ご迷惑をおかけして申し訳ありません。早急に問題を解決し、復旧いたします。
APIに制限があるのかな。getNextCursor()をずっと続けていると駄目だなぁ。


ソース
PagableResponseList<User> users = twitter.getFollowersStatuses("yukari_tamura", -1L);
while (true) {
    
    // 王国民の取得
    
    Thread.sleep(15000);
    if (users.hasNext()) {
        users = twitter.getFollowersStatuses("yukari_tamura", users.getNextCursor());
    } else {
        break;
    }
}
対策:「間隔置いてリトライすれば特に問題ない。」
Twitterさんの負荷が高すぎて、レスポンスを返せないだけ。5~6回連続で失敗するようなら、本当に落ちているのかもしれませんね。

theme : Twitter
genre : コンピュータ

tag : Twitter API

comment

管理者にだけメッセージを送る

カテゴリ
プロフィール

Author:Ay

最新記事
月別アーカイブ
検索フォーム
リンク