Adding new features to Streaming API


#1

To ensure a more consistent experience for our Streaming API consumers across Streaming API and web browser we will be adding new features to the Streaming API. These changes will be rolling out in the next few weeks. Below is the list of the new fields that will be added and their detailed JSON examples.

  1. Timestamps - This will be a timestamp value that will be added to every event that is delivered via streaming API, it will help in establishing the ordering of the event by providing millisecond granularity associated with events.

  2. Mute messages - It will allow consumers of Twitter’s userstream and sitestream to honor users’ mute preferences by avoiding rendering messages the user has indicated they don’t want to see. For a userstream or sitestream, only the source of the mute will see the mute or unmute in the stream.

  3. Multiple Media Entities - We are planning to support multi photo tagging in streaming API by providing additional details in metadata associated with multi photo rendering.

Detailed JSON Examples

Timestamps:
This will include a field named “timestamp_ms” at the top level in the JSON to indicate the time at which the event was created. Its value maps is measured in milliseconds since January 1, 1970 (midnight UTC) and is quoted as a string.

{
“event_name”:
{

“timestamp_ms”: “1403907978000”
}
}

</p>

The list of events that correspond to the event_name value are:

user_protect
user_unprotect
user_suspend
user_unsuspend
user_delete
user_undelete
user_withheld
status_withheld
delete
scrub_geo
limit
warning



In addition the events listed above, every Tweet will also contain timestamp_ms field at the top level in JSON.
<a href="url">https://dev.twitter.com/docs/platform-objects/tweets</a>

<tt>Mute/Unmute:</tt>
A new event named mute and unmute shall be added to indicate if a user has chosen to mute or unmute some follower. Within this event there will be another field “target” which will contain user object indicating if the event has been muted or unmuted for a given follower. This will be sent only to the person who initiated the mute, i.e. the source. and is quoted as a string.

<code linenumbers="off">
{
   "event": "unmute",
   "source": { ... },
   "target": { ... },
   "created_at": "Mon Apr 24 21:24:59 +0000 2014"
}
{ "event": "mute", "source": { ... }, "target": { ... }, "created_at": "Mon Apr 24 21:28:59 +0000 2014" } ```

An example of user object that will be in target is shown below.

“target”: {
“muting”: false
"id": 2467267646,
“id_str”: “2467267646”,
“name”: “Bharati Prasad”,
“screen_name”: “prasadbharati2”,
“location”: null,
“url”: null,
“description”: null,
“protected”: false,
“followers_count”: 1,
“friends_count”: 10,
“listed_count”: 0,
“created_at”: “Mon Apr 28 05:44:22 +0000 2014”,
“favourites_count”: 0,
“utc_offset”: null,
“time_zone”: null,
“geo_enabled”: false,
“verified”: false,
“statuses_count”: 7,
“lang”: “en”,
“contributors_enabled”: false,
“is_translator”: false,
“is_translation_enabled”: false,
“profile_background_color”: “C0DEED”,
“profile_background_image_url”: “http://abs.twimg.com/images/themes/theme1/bg.png”,
“profile_background_image_url_https”: “https://abs.twimg.com/images/themes/theme1/bg.png”,
“profile_background_tile”: false,
“profile_image_url”: “http://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png”,
“profile_image_url_https”: “https://abs.twimg.com/sticky/default_profile_images/default_profile_4_normal.png”,
“profile_link_color”: “0084B4”,
“profile_sidebar_border_color”: “C0DEED”,
“profile_sidebar_fill_color”: “DDEEF6”,
“profile_text_color”: “333333”,
“profile_use_background_image”: true,
“default_profile”: true,
“default_profile_image”: true,
“following”: true,
“follow_request_sent”: false,
“notifications”: false
}



<tt>Multiple Media Entities:</tt>
List of all the photos with their metadata shall be contained in “extended_entities” field for a multi photo tweet.  Within this there can be upto four unique photos which are referenced by the same url i.e. by the display url which is “pic.twitter.com/fxmuQN9JL9” in the JSON below. The field indices in “extended_entitites” indicates the position in tweet the display url is written.

We are introducing extended_entities to support the representation of multiple media entities in the text of the tweet as a single URL. One important detail to understand, the ranges for these entities will overlap, meaning that multiple images will be represented by a single link, whereas before each image had a text range/url.

Tweet URL referenced in the JSON below: 
<a href="url">https://twitter.com/FLOTUS/status/449660889793581056</a>

“entities”: {
“hashtags”: [],
“media”: [
{
“display_url”: “pic.twitter.com/fxmuQN9JL9”,
“expanded_url”: “http://twitter.com/FLOTUS/status/449660889793581056/photo/1”,
“id”: 449660809380380673,
“id_str”: “449660809380380673”,
“indices”: [
121,
143
],
“media_url”: “http://pbs.twimg.com/media/Bj2EH6yIQAEYvxu.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/Bj2EH6yIQAEYvxu.jpg”,
“sizes”: {
“large”: {
“h”: 426,
“resize”: “fit”,
“w”: 640
},
“medium”: {
“h”: 399,
“resize”: “fit”,
“w”: 600
},
“small”: {
“h”: 226,
“resize”: “fit”,
“w”: 340
},
“thumb”: {
“h”: 150,
“resize”: “crop”,
“w”: 150
}
},
“type”: “photo”,
“url”: “http://t.co/fxmuQN9JL9
}
],
“symbols”: [],
“urls”: [],
“user_mentions”: []
},
“extended_entities”: {
“media”: [
{
“display_url”: “pic.twitter.com/fxmuQN9JL9”,
“expanded_url”: “http://twitter.com/FLOTUS/status/449660889793581056/photo/1”,
“id”: 449660809380380673,
“id_str”: “449660809380380673”,
“indices”: [
121,
143
],
“media_url”: “http://pbs.twimg.com/media/Bj2EH6yIQAEYvxu.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/Bj2EH6yIQAEYvxu.jpg”,
“sizes”: {
“large”: {
“h”: 426,
“resize”: “fit”,
“w”: 640
},
“medium”: {
“h”: 399,
“resize”: “fit”,
“w”: 600
},
“small”: {
“h”: 226,
“resize”: “fit”,
“w”: 340
},
“thumb”: {
“h”: 150,
“resize”: “crop”,
“w”: 150
}
},
“type”: “photo”,
“url”: “http://t.co/fxmuQN9JL9
},
{
“display_url”: “pic.twitter.com/fxmuQN9JL9”,
“expanded_url”: “http://twitter.com/FLOTUS/status/449660889793581056/photo/1”,
“id”: 449660806754738177,
“id_str”: “449660806754738177”,
“indices”: [
121,
143
],
“media_url”: “http://pbs.twimg.com/media/Bj2EHxAIIAE8dtg.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/Bj2EHxAIIAE8dtg.jpg”,
“sizes”: {
“large”: {
“h”: 426,
“resize”: “fit”,
“w”: 640
},
“medium”: {
“h”: 399,
“resize”: “fit”,
“w”: 600
},
“small”: {
“h”: 226,
“resize”: “fit”,
“w”: 340
},
“thumb”: {
“h”: 150,
“resize”: “crop”,
“w”: 150
}
},
“type”: “photo”,
“url”: “http://t.co/fxmuQN9JL9
},
{
“display_url”: “pic.twitter.com/fxmuQN9JL9”,
“expanded_url”: “http://twitter.com/FLOTUS/status/449660889793581056/photo/1”,
“id”: 449660808537333761,
“id_str”: “449660808537333761”,
“indices”: [
121,
143
],
“media_url”: “http://pbs.twimg.com/media/Bj2EH3pIYAE4LQn.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/Bj2EH3pIYAE4LQn.jpg”,
“sizes”: {
“large”: {
“h”: 427,
“resize”: “fit”,
“w”: 640
},
“medium”: {
“h”: 400,
“resize”: “fit”,
“w”: 600
},
“small”: {
“h”: 227,
“resize”: “fit”,
“w”: 340
},
“thumb”: {
“h”: 150,
“resize”: “crop”,
“w”: 150
}
},
“type”: “photo”,
“url”: “http://t.co/fxmuQN9JL9
},
{
“display_url”: “pic.twitter.com/fxmuQN9JL9”,
“expanded_url”: “http://twitter.com/FLOTUS/status/449660889793581056/photo/1”,
“id”: 449660877097406464,
“id_str”: “449660877097406464”,
“indices”: [
121,
143
],
“media_url”: “http://pbs.twimg.com/media/Bj2EL3DIEAAzGAX.jpg”,
“media_url_https”: “https://pbs.twimg.com/media/Bj2EL3DIEAAzGAX.jpg”,
“sizes”: {
“large”: {
“h”: 426,
“resize”: “fit”,
“w”: 640
},
“medium”: {
“h”: 399,
“resize”: “fit”,
“w”: 600
},
“small”: {
“h”: 226,
“resize”: “fit”,
“w”: 340
},
“thumb”: {
“h”: 150,
“resize”: “crop”,
“w”: 150
}
},
“type”: “photo”,
“url”: “http://t.co/fxmuQN9JL9
}
]
},


Timestamp_ms is missing from the retweeted_status object
#2

The mute has no effect on the search result. Is this by design? If so, it doesn’t make sense to allow muted users to be visible in the search result.
Thanks,


#3

Answered on this thread