Sampled stream v1
API reference contents
GET /labs/1/tweets/stream/sample
Streams about 1% of all Tweets in real-time.
Endpoint URL
https://api.twitter.com/labs/1/tweets/stream/sampleAuthentication and rate limits
| Authentication methods supported by this endpoint | |
|---|---|
| Rate limit | 50 requests per 15-minute window |
Learn more about rate limits.
Query parameters
| Name | Type | Description |
|---|---|---|
expansionsOptional | enum (attachments.poll_ids, attachments.media_keys, author_id, entities.mentions.username, geo.place_id, in_reply_to_user_id, referenced_tweets.id, referenced_tweets.id.author_id) | Comma-separated list of fields to expand. Expansions enable requests to expand an ID into a full object in the includes response object. |
formatOptional | enum (compact, default, detailed) | Format for all the objects returned as part of the response, including those returned in expansions. |
place.formatOptional | enum (compact, default, detailed) | Format for all Place objects returned in response. Can be used together with other format parameters to expand or reduce Place objects only. |
tweet.formatOptional | enum (compact, default, detailed) | Format for all Tweet objects returned in response. Can be used together with other format parameters to expand or reduce Tweet objects only. |
user.formatOptional | enum (compact, default, detailed) | Format for all User objects returned in response. Can be used together with other format parameters to expand or reduce User objects only. |
Examples
- cURL
curl -X GET -H "Authorization: Bearer $BEARER_TOKEN" "https://api.twitter.com/labs/1/tweets/stream/sample"
Response
- Default format
- Compact format
- Detailed format
{
"data": {
"id": "1189226081406083073",
"created_at": "2019-10-29T17:02:47.000Z",
"text": "Sharing Tweets in DMs is our love language. Today, for Android users, we’re making that easier.",
"author_id": "783214",
"in_reply_to_user_id": "783214",
"referenced_tweets": [
{
"type": "replied_to",
"id": "1151997885455581185"
}
],
"format": "default"
}
}
{
"data": {
"id": "1189226081406083073",
"created_at": "2019-10-29T17:02:47.000Z",
"text": "Sharing Tweets in DMs is our love language. Today, for Android users, we’re making that easier.",
"author_id": "783214",
"in_reply_to_user_id": "783214",
"referenced_tweets": [
{
"type": "replied_to",
"id": "1151997885455581185"
}
],
"format": "compact"
}
}
{
"data": {
"id": "1189226081406083073",
"created_at": "2019-10-29T17:02:47.000Z",
"text": "Sharing Tweets in DMs is our love language. Today, for Android users, we’re making that easier. See more details: https://t.co/eu1upmY4yo",
"author_id": "783214",
"in_reply_to_user_id": "783214",
"referenced_tweets": [
{
"type": "replied_to",
"id": "1151997885455581185"
}
],
"entities": {
"urls": [
{
"start": 113,
"end": 137,
"url": "https://t.co/eu1upmY4yo",
"expanded_url": "http://developer.twitter.com",
"display_url": "developer.twitter.com",
"status": 200,
"title": "Developers Tap into What’s Happening",
"description": "Discover the power of Twitter APIs"
}
],
"annotations": [
{
"start": 55,
"end": 61,
"probability": 0.9596,
"type": "Product",
"normalized_text": "Android"
}
]
},
"stats": {
"retweet_count": 341,
"reply_count": 372,
"like_count": 2773,
"quote_count": 70
},
"possibly_sensitive": false,
"lang": "en",
"source": "<a href=\"https://mobile.twitter.com\" rel=\"nofollow\">Twitter Web App</a>",
"context_annotations": [
{
"domain": {
"id": "45",
"name": "Brand Vertical",
"description": "Top level entities that describe a Brands industry"
},
"entity": {
"id": 781974596165640193,
"name": "Technology",
"description": "This entity includes conversation about Information Technology"
}
},
{
"domain": {
"id": "46",
"name": "Brand Category",
"description": "Categories within Brand Verticals that narrow down the scope of Brands"
},
"entity": {
"id": 10026820777,
"name": "Android",
"description": "Mobile operating system based on the Linux kernel."
}
}
],
"format": "detailed"
}
}
Response fields
| Name | Type | Description |
|---|---|---|
id | string | Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. |
created_at | date (ISO 8601) | Creation time of the Tweet. |
text | string | The content of the Tweet. |
author_id | string | Unique identifier of this User. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. You can obtain the expanded object in includes.users by adding expansions=author_id in the request's query parameter. |
in_reply_to_user_id | string | If this Tweet is a reply, indicates the User ID of the parent Tweet's author. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. You can obtain the expanded object in includes.users by adding expansions=in_reply_to_user_id in the request's query parameter. |
referenced_tweets | array | A list of Tweets this Tweet refers to. For example, if the parent Tweet is a Retweet, a Quoted Tweet or a Reply, it will include the related Tweet referenced to by its parent. |
referenced_tweets.type | enum (retweeted, quoted, replied_to) | Indicates the type of relationship between this Tweet and the Tweet returned in the response: retweeted (this Tweet is a Retweet), quoted (a Retweet with comment, also known as Quoted Tweet), or replied_to (this Tweet is a reply). |
referenced_tweets.id | string | The unique identifier of the referenced Tweet. You can obtain the expanded object in includes.tweets by adding expansions=referenced_tweets.id in the request's query parameter. |
referenced_tweets.id.author_id | string | The unique identifier of the author of the referenced Tweet. You can obtain the expanded object in includes.users by adding expansions=referenced_tweets.id.author_id in the request's query parameter. |
attachments | object | Specifies the type of attachments (if any) present in this Tweet. |
attachments.media_keys | array | List of unique identifiers of media attached to this Tweet. These identifiers use the same media key format as those returned by the Media Library. You can obtain the expanded object in includes.media by adding expansions=attachments.media_keys in the request's query parameter. |
attachments.poll_ids | array | List of unique identifiers of polls present in the Tweet delivered. These are returned as a string in order to avoid complications with languages and tools that cannot handle large integers. You can obtain the expanded object in includes.polls by adding expansions=attachments.polls_ids in the request's query parameter. |
geo | object | Contains details about the location tagged by the user in this Tweet, if they specified one. |
geo.coordinates.type | string | Describes the type of coordinate. The only value supported at present is Point. |
geo.coordinates.coordinates | array | A pair of decimal values representing the precise location of the user (latitude, longitude). This value be null unless the user explicitly shared their precise location. |
geo.place_id | string | The unique identifier of the place, if this is a point of interest tagged in the Tweet. You can obtain the expanded object in includes.places by adding expansions=geo.place_id in the request's query parameter. |
entities | object | Contains details about text that has a special meaning in a Tweet. |
entities.url | array | Contains details about text recognized as a URL. |
entities.url.start | integer | The start position (zero-based) of the recognized URL within the Tweet. |
entities.url.end | integer | The end position (zero-based) of the recognized URL within the Tweet. |
entities.url.url | string | The URL in the format Tweeted by the user. |
entities.url.expanded_url | string | The fully resolved URL. |
entities.url.display_url | string | The URL as displayed in the Twitter client. |
entities.urls.display_url | string | The URL as displayed in the Twitter client. |
entities.urls.status | string | The status code of the URL. |
entities.urls.title | string | The title of the web page. |
entities.urls.description | string | The description of the document. |
entities.annotations | array | Contains details about annotations relative to the text within a Tweet. |
entities.annotations.start | integer | The start position (zero based) of the text used to annotate the Tweet. |
entities.annotations.end | integer | The end position (zero based) of the text used to annotate the Tweet. |
entities.annotations.probability | number | The confidence score for the annotation as it correlates to the Tweet text. |
entities.annotations.type | string | The description of the type of entity identified when the Tweet text was interpreted. |
entities.annotations.normalized_text | string | The text used to determine the annotation type. |
entities.hashtags | array | Contains details about text recognized as a hashtag. |
entities.hashtags.start | integer | The start position (zero-based) of the recognized hashtag within the Tweet. |
entities.hashtags.end | integer | The end position (zero-based) of the recognized hashtag within the Tweet. |
entities.hashtags.hashtag | string | The text of the hashtag. |
entities.mentions | array | Contains details about text recognized as a user mention. |
entities.mentions.start | integer | The start position (zero-based) of the recognized user mention within the Tweet. |
entities.mentions.end | integer | The end position (zero-based) of the recognized user mention within the Tweet. |
entities.mentions.username | string | The part of text recognized as a user mention. You can obtain the expanded object in includes.users by adding expansions=entities.mentions.username in the request's query parameter. |
entities.cashtags | array | Contains details about text recognized as a cashtag. |
entities.cashtags.start | integer | The start position (zero-based) of the recognized cashtag within the Tweet. |
entities.hashtags.end | integer | The end position (zero-based) of the recognized cashtag within the Tweet. |
entities.cashtags.cashtag | string | The text of the cashtag. |
withheld | object | Contains withholding details for withheld content. |
withheld.copyright | boolean | Indicates if the content is being withheld for on the basis of copyright infringement. |
withheld.country_codes | array | Provides a list of countries where this content is not available. |
withheld.scope | enum (tweet, user) | Indicates whether the content being withheld is a Tweet or a user. |
stats | object | Engagement metrics for the Tweet at the time of the request. |
stats.retweet_count | integer | Number of times this Tweet has been Retweeted. |
stats.reply_count | integer | Number of replies of this Tweet. |
stats.like_count | integer | Number of Likes of this Tweet. |
stats.quote_count | integer | Number of times this Tweet has been Retweeted with a comment (also known as Quote). |
possibly_sensitive | boolean | Indicates if this Tweet contains URLs marked as sensitive, for example content suitable for mature audiences. |
lang | string | Language of the Tweet, if detected by Twitter. Returned as a BCP47 language tag. |
source | string | The name of the app the user Tweeted from. |
context_annotations | object | Contains context annotations for the Tweet. |
context_annotations.domain | array | Contains elements which identify detailed information regarding the domain classification based on Tweet text. |
context_annotations.domain.id | integer | Contains the numeric value of the domain. |
context_annotations.domain.name | string | Domain name based on the Tweet text. |
context_annotations.domain.description | string | Long form description of domain classification. |
context_annotations.entity | array | Contains elements which identify detailed information regarding the domain classification bases on Tweet text. |
context_annotations.entity.id | integer | Unique value which correlates to an explicitly mentioned Person, Place, Product or Organization |
context_annotations.entity.name | string | Name or reference of entity referenced in the Tweet. |
context_annotations.entity.description | string | Additional information regarding referenced entity. |
format | enum (default, compact, detailed) | Indicates the format returned for this object, as requested in the format or tweet.format query parameters. |
includes | object | Returns the requested expansions, if available. |
includes.tweets | array | For referenced Tweets, this is a list of objects with the same structure as the one described in this page. |
includes.users | array | For referenced users, this is a list of objects with the same structure as the one described by GET /users. |
includes.places.id | string | The unique identifier of the place, if this is a point of interest tagged in the Tweet. |
includes.places.name | string | The short name of this place, for example San Francisco. |
includes.places.full_name | string | A longer-form detailed place name, for example San Francisco, CA. |
includes.places.place_type | enum (city, unknown, country, admin, neighborhood, poi, zip_code, metro, admin0, admin1) | Specified the particular type of information represented by this place information, such as a city name, or a point of interest. |
includes.places.country_code | string | The ISO Alpha-2 country code this place belongs to. |
includes.places.country | string | The full-length name of the country this place belongs to. |
includes.places.contained_within | array | Returns the identifiers of known places that contain the referenced place. |
includes.places.geo | object | Contains place details in GeoJSON format. |
includes.places.geo.type | string | The type of place described by this object. At present, this API only returns objects of type Feature. |
includes.places.geo.bbox | array | The bounding box coordinates for this place (latitude_start, longitude_start, latitude_end, longitude_end). |
includes.places.geo.geometry | object | Contains GeoJSON point information for this place, if available. |
includes.places.geo.coordinates.type | string | Describes the type of coordinate. The only value supported at present is Point. |
includes.places.geo.coordinates.coordinates | array | A pair of decimal values representing the precise location of the user (latitude, longitude). This value be null unless the user explicitly shared their precise location. |
includes.places.geo.coordinates.properties | object | A dictionary containing additional properties, as defined by the GeoJSON specification. Can be empty. |
includes.media | string | For referenced media attachments, this is a list of objects describing media content. |
includes.media.media_key | string | Unique identifiers for this expanded media content. This is returned using the same media key format as returned by the Media Library. |
includes.media.height | integer | Height of this content in pixels. |
includes.media.width | integer | Width of this content in pixels. |
includes.media.preview_image_url | string | URL to the static placeholder preview of this content. |
includes.media.duration_ms | integer | Available when `includes.media.type` is `video`. Duration in milliseconds of the video. |
includes.media.type | enum (animated_gif, photo, video) | Type of content. |
includes.polls | string | For referenced polls, this is a list of objects describing polls. |
includes.polls.id | string | Unique identifiers of the expanded poll. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. |
includes.polls.options | array | Contains objects describing each choice in the referenced poll. |
includes.polls.options.position | integer | Position of this choice in the poll. |
includes.polls.options.label | string | Text of the poll choice. |
includes.polls.options.votes | integer | Number of votes this poll choice received. |
includes.polls.options.voting_status | enum (open, closed) | Indicates if this poll is still active and can receive votes, or if the voting is now closed. |
includes.polls.end_datetime | number | Specifies the end date and time for this poll. |
includes.polls.duration_minutes | integer | Specifies the total duration of this poll. |