spring-boottwitterhttp-status-code-429

Unexpected rate limit on Twitter API V2: POST Create a Tweet


I am using the new to the Twitter API and I've got the following response:

2023-08-31T17:20:45,339+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - date: Thu, 31 Aug 2023 15:20:45 UTC
2023-08-31T17:20:45,340+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - perf: 7626143928
2023-08-31T17:20:45,340+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - server: tsa_o
2023-08-31T17:20:45,340+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - set-cookie: guest_id=v1%3A169349524526667769; Max-Age=34214400; Expires=Mon, 30 Sep 2024 15:20:45 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
2023-08-31T17:20:45,340+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - api-version: 2.66
2023-08-31T17:20:45,340+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - content-type: application/json; charset=utf-8
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - cache-control: no-cache, no-store, max-age=0
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-access-level: read-write
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-frame-options: SAMEORIGIN
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-transaction-id: 0aae29f6c3ab4659
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-xss-protection: 0
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-rate-limit-limit: 40000
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-rate-limit-reset: 1693496145
2023-08-31T17:20:45,341+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - content-disposition: attachment; filename=json.json
2023-08-31T17:20:45,344+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-content-type-options: nosniff
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-rate-limit-remaining: 39999
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-app-limit-24hour-limit: 50
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-app-limit-24hour-reset: 1693508848
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - strict-transport-security: max-age=631138519
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-user-limit-24hour-limit: 50
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-user-limit-24hour-reset: 1693508848
2023-08-31T17:20:45,345+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-app-limit-24hour-remaining: 0
2023-08-31T17:20:45,346+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-user-limit-24hour-remaining: 0
2023-08-31T17:20:45,346+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-response-time: 113
2023-08-31T17:20:45,346+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - x-connection-hash: ae60d58d805b62c8c905c3d1ab6cf69c071b785bc30b00f39b9f89f32551f152
2023-08-31T17:20:45,347+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - 
2023-08-31T17:20:45,347+02:00 [scheduling-1] INFO  okhttp3.OkHttpClient - {"title":"Too Many Requests","detail":"Too Many Requests","type":"about:blank","status":429}

Solution

  • Error message is clearly saying "Too Many Requests". According to https://developer.twitter.com/en/docs/twitter-api/rate-limits limit for posting is

    Endpoint        #Requests   Window of time  Per     Part of the Tweet pull cap?     Effective 30-day limit
    POST_2_tweets   100         24 hours    per user    no                               3,000
    

    100 post is the limit for 24 hours.