Poll object

Poll

A poll included in a Tweet is not a primary object on any endpoint, but can be found and expanded in the Tweet object. 

The object is available for expansion with ?expansions=attachments.poll_ids to get the condensed object with only default fields. Use the expansion with the field parameter: poll.fields when requesting additional fields to complete the object.

 

Field value Type Description

id (default)

string

Unique identifier of the expanded poll.

"id": "1199786642791452673"

options (default)

array

Contains objects describing each choice in the referenced poll.

"options": [
                   {
                       "position": 1,
                       "label": "“C Sharp”",
                       "votes": 795
                   },
                   {
                       "position": 2,
                       "label": "“C Hashtag”",
                       "votes": 156
                   }
               ]

duration_minutes

integer

Specifies the total duration of this poll.

"duration_minutes": 1440

end_datetime

date (ISO 8601)

Specifies the end date and time for this poll.

"end_datetime": "2019-11-28T20:26:41.000Z"

voting_status

string

Indicates if this poll is still active and can receive votes, or if the voting is now closed.

"voting_status": "closed"

Retrieving a poll object

Sample Request

In the following request, we are requesting fields for the poll object attached to the Tweet on the Tweets lookup endpoint. Since poll is a child object of a Tweet, the attachments.poll_id expansion is required. Be sure to replace $BEARER_TOKEN with your own generated Bearer Token.
 

      curl --request GET 'https://api.x.com/2/tweets?ids=1199786642791452673&expansions=attachments.poll_ids&poll.fields=duration_minutes,end_datetime,id,options,voting_status' --header 'Authorization: Bearer $BEARER_TOKEN'
    


Sample Response
 

      {
    "data": [
        {
            "text": "C#",
            "id": "1199786642791452673",
            "attachments": {
                "poll_ids": [
                    "1199786642468413448"
                ]
            }
        }
    ],
    "includes": {
        "polls": [
            {
                "id": "1199786642468413448",
                "voting_status": "closed",
                "duration_minutes": 1440,
                "options": [
                    {
                        "position": 1,
                        "label": "“C Sharp”",
                        "votes": 795
                    },
                    {
                        "position": 2,
                        "label": "“C Hashtag”",
                        "votes": 156
                    }
                ],
                "end_datetime": "2019-11-28T20:26:41.000Z"
            }
        ]
    }
}