Available on crate feature helix only.
Expand description

Create a poll for a specific Twitch channel. create-poll

Accessing the endpoint

Request: CreatePollRequest

To use this endpoint, construct a CreatePollRequest with the CreatePollRequest::new() method.

use twitch_api2::helix::polls::create_poll;
let request = create_poll::CreatePollRequest::new();

Body: CreatePollBody

We also need to provide a body to the request containing what we want to change.

let body = create_poll::CreatePollBody::builder()
    .broadcaster_id("141981764")
    .title("Heads or Tails?")
    .choices(vec![
        create_poll::NewPollChoice::new("Heads"),
        create_poll::NewPollChoice::new("Tails"),
    ])
    .channel_points_voting_enabled(true)
    .channel_points_per_vote(100)
    .duration(1800)
    .build();

Response: CreatePollResponse

Send the request to receive the response with HelixClient::req_post().

use twitch_api2::helix::{self, polls::create_poll};
let request = create_poll::CreatePollRequest::builder()
    .build();
let body = create_poll::CreatePollBody::builder()
    .broadcaster_id("141981764")
    .title("Heads or Tails?")
    .choices(vec![create_poll::NewPollChoice::new("Heads"), create_poll::NewPollChoice::new("Tails")])
    .channel_points_voting_enabled(true)
    .channel_points_per_vote(100)
    .duration(1800)
    .build();
let response: create_poll::CreatePollResponse = client.req_post(request, body, &token).await?.data;

You can also get the http::Request with request.create_request(&token, &client_id) and parse the http::Response with CreatePollRequest::parse_response(None, &request.get_uri(), response)

Structs

Body Parameters for Create Poll

Query Parameters for Create Poll

Choice settings for a poll

Type Definitions