Search code examples
apitwitter

Why Twitter API returning JSON starting "delete"


Question

Twitter API returns the message with "delete". Please help understand what this means and why the API is returning this message.

{  
   "delete":{  
      "status":{  
         "id":406461955981840384,
         "id_str":"406461955981840384",
         "user_id":****,
         "user_id_str":"****"
      },
      "timestamp_ms":"1562915550977"
   }
}

Before getting this message, I have got 420 (due to limited rate).


Solution

  • This is a status deletion notice from the standard streaming API. According to the Twitter documentation:

    Status deletion notices (delete)

    These messages indicate that a given Tweet has been deleted. Client code must honor these messages by clearing the referenced Tweet from memory and any storage or archive, even in the rare case where a deletion message arrives earlier in the stream that the Tweet it references.

    {
    "delete":{
    "status":{
    "id":1234,
    "id_str":"1234",
    "user_id":3,
    "user_id_str":"3"
    }
    }
    }