GET /2/tweets/compliance/stream

GET /2/tweets/compliance/stream

Connect to one of four partitiona of the Tweet compliance stream.

Endpoint URL

https://api.x.com/2/tweets/compliance/stream

Authentication and rate limits

Authentication methods
supported by this endpoint

OAuth 2.0 App-only

Rate limit

App rate limit (Application-only): 100 requests per 15-minute window shared among all users of your app

Query parameters

NameTypeDescription
partition
 Required 
numberMust be set to 1, 2, 3 or 4. Tweet compliance events are split across 4 partitions, so 4 separate streams are needed to receive all events.
backfill_minutes
 Optional 
numberBy passing this parameter, you can recover up to five minutes worth of data that you might have missed during a disconnection. The backfilled events will automatically flow through a reconnected stream, with older events generally being delivered before any newer events. You must include a whole number between 1 and 5 as the value to this parameter. nThis feature will deliver all events that published during the timeframe selected, meaning that if you were disconnected for 90 seconds, and you requested two minutes of backfill, you will receive 30 seconds worth of duplicate events. Due to this, you should make sure your system is tolerant of duplicate data.


Example code with offical SDKs

TypeScript
Java
      (async () => {
  try {
    const tweetComplianceStream = await twitterClient.tweets.complianceStream();
    console.dir(tweetComplianceStream, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

    
      try {
    InputStream result = apiInstance.tweets().complianceStream(null, null, null, null, null, null, null);
    try{
        JSON json = new JSON();
        Type localVarReturnType = new TypeToken<StreamingTweetCompliance>(){}.getType();
        BufferedReader reader = new BufferedReader(new InputStreamReader(result));
        String line = reader.readLine();
        while (line != null) {
          System.out.println(json.getGson().fromJson(line, localVarReturnType).toString());
          line = reader.readLine();
        }
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println(e);
    }
} catch (ApiException e) {
    System.err.println("Exception when calling TweetsApi#tweetsComplianceStream");
    System.err.println("Status code: " + e.getCode());
    System.err.println("Reason: " + e.getResponseBody());
    System.err.println("Response headers: " + e.getResponseHeaders());
    e.printStackTrace();
}    

    

Example responses

Successful response
      {
  "data": {
    "delete": {
      "tweet": {
        "id": "1542870758724145153",
        "author_id": "906948460078698496"
      },
      "event_at": "2022-07-01T21:48:43.030Z"
    }
  }
}
    

Response fields

NameTypeDescription
deletestringA delete Tweet event.
withheldstringA withheld Tweet event.
dropstringA drop Tweet event.
undropstringA undrop Tweet event.
idstringThe ID of the Tweet triggering a compliance event.
author_idstringThe ID of the author of a Tweet triggering a compliance event.
event_atdate (ISO 8601)Time of when event happended.