Skip to main content

kick_api/models/
livestream.rs

1use serde::{Deserialize, Serialize};
2
3/// A currently live stream with category and broadcaster info
4///
5/// Returned by the `GET /livestreams` endpoint.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct Livestream {
8    /// The broadcaster's user ID
9    pub broadcaster_user_id: u64,
10
11    /// Stream category info
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub category: Option<LivestreamCategoryInfo>,
14
15    /// Channel ID
16    pub channel_id: u64,
17
18    /// Custom tags set by the streamer
19    #[serde(default)]
20    pub custom_tags: Vec<String>,
21
22    /// Whether the stream is marked as mature
23    pub has_mature_content: bool,
24
25    /// Stream language code (e.g., "en")
26    pub language: String,
27
28    /// Broadcaster's profile picture URL
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub profile_picture: Option<String>,
31
32    /// Channel slug (username)
33    pub slug: String,
34
35    /// When the stream started (ISO 8601)
36    pub started_at: String,
37
38    /// Stream title
39    pub stream_title: String,
40
41    /// Thumbnail URL
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub thumbnail: Option<String>,
44
45    /// Current viewer count
46    pub viewer_count: u64,
47}
48
49/// Category info within a livestream response
50#[derive(Debug, Clone, Serialize, Deserialize)]
51pub struct LivestreamCategoryInfo {
52    /// Category ID
53    pub id: u32,
54
55    /// Category name
56    pub name: String,
57
58    /// Category slug
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub slug: Option<String>,
61}
62
63/// Global livestream statistics
64///
65/// Returned by the `GET /livestreams/stats` endpoint.
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct LivestreamStats {
68    /// Total number of live streams on Kick right now
69    pub total_count: u64,
70}
71
72/// Sort order for livestream queries
73#[derive(Debug, Clone, Copy)]
74pub enum LivestreamSort {
75    /// Sort by viewer count (highest first) — default
76    ViewerCount,
77    /// Sort by stream start time (most recent first)
78    StartedAt,
79}
80
81impl LivestreamSort {
82    pub(crate) fn as_str(&self) -> &'static str {
83        match self {
84            LivestreamSort::ViewerCount => "viewer_count",
85            LivestreamSort::StartedAt => "started_at",
86        }
87    }
88}