kickcom

package module
v0.0.0-...-a1fe3d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2025 License: CC0-1.0 Imports: 14 Imported by: 3

README

To be deprecated

Kick.com finally published the API documentation. After the required features will be implemented (&published) this package will be deprecated/archived.

Here are some examples of packages that are implemented based on the offical documentation:

About

Go Reference Go Report Card

This is package for Go that implements a client to Kick.com API.

Currently, it supports only a couple of features, but feel free to extend it.

Backstory

Unfortunately, Kick stuff does not respond me for more than a year on a request to provide docs to their API, and on questions "when?" they respond with:

[...] we do not have an estimated time of when our relevant team will respond to your request. We may only advise you to remain patient and they will respond to your request in due time.

So I had to start reverse engineering how it works. This package is the result of this effort.

How to use

An example how to get the current chat messages in the chat, given the channel's slug:

package main

import "github.com/davecgh/go-spew/spew"
import "github.com/xaionaro-go/kickcom"

func main() {
    ...

	k, err := kickcom.New()
	if err != nil { ... }

	channel, err := k.GetChannelV1(ctx, channelSlug)
	if err != nil { ... }

	reply, err := k.GetChatMessagesV2(ctx, channel.ID, 0)
	if err != nil { ... }

	for _, msg := range reply.Data.Messages {
		spew.Dump(msg)
	}

    ...
}

Documentation

Index

Constants

View Source
const (
	// RouteSubcategoriesAll is a route to the endpoint to get all subcategories using API v1.
	RouteSubcategoriesAll = Route("subcategories.all")

	// RouteChannelsShow is a route to the endpoint to get channel info using API v1.
	RouteChannelsShow = Route("channels.show")

	// RouteChannelLivestream is a route to the endpoint to get channel livestream info using API v2.
	RouteChannelLivestream = Route("channel.livestream")

	// RouteChatHistoryChannelMessages is a route to the endpoint to get channel messages history.
	RouteChatHistoryChannelMessages = Route("chat-history.channel-messages")

	// RouteDeleteChatMessage is a route to the endpoint to delete a chat message.
	RouteDeleteChatMessage = Route("delete.chatmessage")

	// RouteChatRoomGetRules is a route to the endpoint to get chat room rules using API v2.
	RouteChatRoomGetRules = Route("chatroom.getRules")

	// RouteChatRoomShow is a route to the endpoint to get chat room info using API v1.
	RouteChatRoomShow = Route("chatroom.show")

	// RouteChatRoomShow is a route to the endpoint to get chat room info using API v2.
	RouteChannelChatRoom = Route("channel.chatroom")

	// RouteKickTokenCreate is a route to the endpoint to create kick token (for authentication).
	RouteKickTokenCreate = Route("kick.token.create")

	// RouteSwaggerGetDocs is a route to the endpoint to get swagger docs. IT DOES NOT WORK.
	RouteSwaggerGetDocs = Route("swagger.getDocs")
)

Variables

View Source
var NoBody noBodyT

NoBody is a request that could be used in function `Request` to signify that there is no request body.

Functions

func GetURL

func GetURL(
	route Route,
	routeVars RouteVars,
) *url.URL

GetURL returns an URL of the requested endpoint.

func Request

func Request[REPLY any, REQUEST any](
	ctx context.Context,
	k *Kick,
	httpMethod string,
	route Route,
	routeVars RouteVars,
	uriValues url.Values,
	request REQUEST,
) (_ret *REPLY, _err error)

Request performs a request to Kick's backend.

Types

type BadgeV2

type BadgeV2 struct {
	Type   string `json:"type"`
	Text   string `json:"text"`
	Active bool   `json:"active"`
	Count  int    `json:"count,omitempty"`
}

BadgeV2 is a representation of a badge in the API v2.

type BannerImageV1

type BannerImageV1 struct {
	Responsive string `json:"responsive"`
	URL        string `json:"url"`
}

BannerImageV1 is a representation of a banner image in the API v1.

type CategoriesV1Reply

type CategoriesV1Reply []CategoryV1Short

CategoriesV1Reply is the response provided by GetCategoriesV1

type CategoryV1

type CategoryV1 struct {
	ID          uint64          `json:"id"`
	CategoryID  uint64          `json:"category_id"`
	Name        string          `json:"name"`
	Slug        string          `json:"slug"`
	Tags        []string        `json:"tags"`
	Description any             `json:"description"`
	DeletedAt   any             `json:"deleted_at"`
	Viewers     uint64          `json:"viewers"`
	Category    CategoryV1Short `json:"category"`
}

CategoryV1 is a full representation of a category in the API v1.

type CategoryV1Short

type CategoryV1Short struct {
	ID       uint64 `json:"id"`
	Name     string `json:"name"`
	Slug     string `json:"slug"`
	Icon     string `json:"icon,omitempty"`
	IsMature bool   `json:"is_mature"`
}

CategoryV1Short is a representation of a category essentials in the API v1.

type CategoryV2

type CategoryV2 struct {
	ID             int      `json:"id"`
	Name           string   `json:"name"`
	Slug           string   `json:"slug"`
	Tags           []string `json:"tags"`
	ParentCategory struct {
		ID   int    `json:"id"`
		Slug string `json:"slug"`
	} `json:"parent_category"`
}

type ChannelV1

type ChannelV1 struct {
	ID                  uint64              `json:"id"`
	UserID              uint64              `json:"user_id"`
	Slug                string              `json:"slug"`
	IsBanned            bool                `json:"is_banned"`
	PlaybackURL         string              `json:"playback_url"`
	NameUpdatedAt       string              `json:"name_updated_at"`
	VodEnabled          bool                `json:"vod_enabled"`
	SubscriptionEnabled bool                `json:"subscription_enabled"`
	FollowersCount      uint64              `json:"followersCount"`
	SubscriberBadges    []SubscriberBadgeV1 `json:"subscriber_badges"`
	BannerImage         BannerImageV1       `json:"banner_image"`
	RecentCategories    []CategoryV1        `json:"recent_categories"`
	Livestream          LivestreamV1        `json:"livestream"`
	Role                any                 `json:"role"`
	Muted               bool                `json:"muted"`
	FollowerBadges      []any               `json:"follower_badges"`
	OfflineBannerImage  ImageV1             `json:"offline_banner_image"`
	CanHost             bool                `json:"can_host"`
	User                UserV1              `json:"user"`
	Chatroom            ChatroomV1Short     `json:"chatroom"`
	AscendingLinks      []LinkV1            `json:"ascending_links"`
	Plan                any                 `json:"plan"`
	PreviousLivestreams []LivestreamV1      `json:"previous_livestreams"`
	Verified            struct {
		ID        uint64    `json:"id"`
		ChannelID uint64    `json:"channel_id"`
		CreatedAt time.Time `json:"created_at"`
		UpdatedAt time.Time `json:"updated_at"`
	} `json:"verified"`
	Media []MediaAssetV1 `json:"media"`
}

ChannelV1 is a representation of a channel in the API v1.

type ChatMessageSenderV2

type ChatMessageSenderV2 struct {
	ID       int        `json:"id"`
	Slug     string     `json:"slug"`
	Username string     `json:"username"`
	Identity IdentityV2 `json:"identity"`
}

ChatMessageSenderV2 is a representation of the sender of a chat message in API v2.

type ChatMessageV2

type ChatMessageV2 struct {
	ID        string              `json:"id"`
	ChatID    int                 `json:"chat_id"`
	UserID    int                 `json:"user_id"`
	Content   string              `json:"content"`
	Type      string              `json:"type"`
	Metadata  any                 `json:"metadata"`
	CreatedAt time.Time           `json:"created_at"`
	Sender    ChatMessageSenderV2 `json:"sender"`
}

ChatMessageSenderV2 is a representation of a chat message in API v2.

type ChatMessagesV2Reply

type ChatMessagesV2Reply struct {
	Status struct {
		Error   bool   `json:"error"`
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"status"`
	Data struct {
		Messages      []ChatMessageV2 `json:"messages"`
		Cursor        string          `json:"cursor"`
		PinnedMessage any             `json:"pinned_message"`
	} `json:"data"`
}

ChatMessageSenderV2 is response in API v2 on a request to provide chat messages.

type ChatroomRulesV2

type ChatroomRulesV2 struct {
	Status struct {
		Error   bool   `json:"error"`
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"status"`
	Data struct {
		Rules string `json:"rules"`
	} `json:"data"`
}

ChatroomRulesV2 is a response to GetChatroomRulesV2.

type ChatroomV1

type ChatroomV1 struct {
	ID                  int             `json:"id"`
	UserID              int             `json:"user_id"`
	Slug                string          `json:"slug"`
	IsBanned            bool            `json:"is_banned"`
	PlaybackURL         string          `json:"playback_url"`
	NameUpdatedAt       any             `json:"name_updated_at"`
	VodEnabled          bool            `json:"vod_enabled"`
	SubscriptionEnabled bool            `json:"subscription_enabled"`
	Role                any             `json:"role"`
	FollowerBadges      []any           `json:"follower_badges"`
	MutedUsers          []any           `json:"muted_users"`
	CanHost             bool            `json:"can_host"`
	Chatroom            ChatroomV1Short `json:"chatroom"`
	Emotes              []EmoteV1       `json:"emotes"`
}

ChatroomV1 is the full representation of a chat room in API v1.

type ChatroomV1Short

type ChatroomV1Short struct {
	ID                   uint64    `json:"id"`
	ChatableType         string    `json:"chatable_type"`
	ChannelID            uint64    `json:"channel_id"`
	CreatedAt            time.Time `json:"created_at"`
	UpdatedAt            time.Time `json:"updated_at"`
	ChatModeOld          string    `json:"chat_mode_old"`
	ChatMode             string    `json:"chat_mode"`
	SlowMode             bool      `json:"slow_mode"`
	ChatableID           uint64    `json:"chatable_id"`
	FollowersMode        bool      `json:"followers_mode"`
	SubscribersMode      bool      `json:"subscribers_mode"`
	EmotesMode           bool      `json:"emotes_mode"`
	MessageInterval      uint64    `json:"message_interval"`
	FollowingMinDuration uint64    `json:"following_min_duration"`
}

ChatroomV1Short is a representation of the chat room essentials in API v1.

type ChatroomV2

type ChatroomV2 struct {
	ID       int `json:"id"`
	SlowMode struct {
		Enabled         bool `json:"enabled"`
		MessageInterval int  `json:"message_interval"`
	} `json:"slow_mode"`
	SubscribersMode struct {
		Enabled bool `json:"enabled"`
	} `json:"subscribers_mode"`
	FollowersMode struct {
		Enabled     bool `json:"enabled"`
		MinDuration int  `json:"min_duration"`
	} `json:"followers_mode"`
	EmotesMode struct {
		Enabled bool `json:"enabled"`
	} `json:"emotes_mode"`
	AdvancedBotProtection struct {
		Enabled       bool `json:"enabled"`
		RemainingTime int  `json:"remaining_time"`
	} `json:"advanced_bot_protection"`
	PinnedMessage   interface{} `json:"pinned_message"`
	ShowQuickEmotes struct {
		Enabled bool `json:"enabled"`
	} `json:"show_quick_emotes"`
	ShowBanners struct {
		Enabled bool `json:"enabled"`
	} `json:"show_banners"`
	GiftsEnabled struct {
		Enabled bool `json:"enabled"`
	} `json:"gifts_enabled"`
	GiftsWeekEnabled struct {
		Enabled bool `json:"enabled"`
	} `json:"gifts_week_enabled"`
	GiftsMonthEnabled struct {
		Enabled bool `json:"enabled"`
	} `json:"gifts_month_enabled"`
}

ChatroomV2 contains the information about the chat room as it is provided by API v2.

type DeleteChatMessageReply

type DeleteChatMessageReply struct{}

DeleteChatMessageReply is a response to a request to delete a chat message.

type EmoteV1

type EmoteV1 struct {
	ID              int    `json:"id"`
	ChannelID       int    `json:"channel_id"`
	Name            string `json:"name"`
	SubscribersOnly bool   `json:"subscribers_only"`
	Image           any    `json:"image"`
}

EmoteV1 is a representation of an emote in API v1.

type IdentityV2

type IdentityV2 struct {
	Color  string    `json:"color"`
	Badges []BadgeV2 `json:"badges"`
}

IdentityV2 is a representation of a user's identity (in the chat?) in API v2.

type ImageV1

type ImageV1 struct {
	Srcset string `json:"srcset"`
	Src    string `json:"src"`
}

ImageV1 is a representation of an image in API v1.

type Kick

type Kick struct {
	*http.Client
}

Kick is a client to Kick.com API.

func New

func New() (*Kick, error)

New returns a new instance of Kick.

func (*Kick) GetChannelV1

func (k *Kick) GetChannelV1(
	ctx context.Context,
	channel string,
) (*ChannelV1, error)

GetChannelV1 returns channel information given channel slug using API v1.

func (*Kick) GetChatMessagesV2

func (k *Kick) GetChatMessagesV2(
	ctx context.Context,
	channelID uint64,
	cursor uint64,
) (*ChatMessagesV2Reply, error)

GetChatMessagesV2 requests a list of messages from the channel using API v2.

func (*Kick) GetChatroomRulesV2

func (k *Kick) GetChatroomRulesV2(
	ctx context.Context,
	channelSlug string,
) (*ChatroomRulesV2, error)

GetChatroomRulesV2 returns the rules of the chat. The function is not tested.

func (*Kick) GetChatroomV1

func (k *Kick) GetChatroomV1(
	ctx context.Context,
	channelSlug string,
) (*ChatroomV1, error)

GetChatroomV1 returns the information about the chat root using API v1. For more details see the fields of ChatroomV1. The function is not tested.

func (*Kick) GetChatroomV2

func (k *Kick) GetChatroomV2(
	ctx context.Context,
	channelSlug string,
) (*ChatroomV2, error)

GetChatroomV2 returns the information about the chat room using API v2. For more details see the fields of ChatroomV2. The function is not tested.

func (*Kick) GetLivestreamV2

func (k *Kick) GetLivestreamV2(
	ctx context.Context,
	channelSlug string,
) (*LivestreamV2Reply, error)

GetLivestreamV2 returns the information about the current live stream using API v2.

func (*Kick) GetSubcategoriesV1

func (k *Kick) GetSubcategoriesV1(
	ctx context.Context,
) (*CategoriesV1Reply, error)

GetCategoriesV1 returns the list of available categories.

func (*Kick) TBDDeleteChatMessage

func (k *Kick) TBDDeleteChatMessage(
	ctx context.Context,
	chatRoomID uint64,
	messageID uint64,
) (*DeleteChatMessageReply, error)

TBDDeleteChatMessage is a To-Be-Developed (TBD) function to delete a chat message. DO NOT USE THIS FUNCTION.

func (*Kick) TBDLogin

func (k *Kick) TBDLogin(
	ctx context.Context,
	email string,
	password string,
) error

TBDLogin is a To-Be-Developed (TBD) function that will do the logging in (when will be complete). DO NOT USE THIS FUNCTION.

func (*Kick) TBDSwaggerGetDocs

func (k *Kick) TBDSwaggerGetDocs(
	ctx context.Context,
) (*map[string]any, error)

TBDSwaggerGetDocs is supposed to return swagger dogs, but it does not work. DO NOT USE THIS FUNCTION

type KickTokenProviderReply

type KickTokenProviderReply struct {
	Enabled                   bool   `json:"enabled"`
	NameFieldName             string `json:"nameFieldName"`
	UnrandomizedNameFieldName string `json:"unrandomizedNameFieldName"`
	ValidFromFieldName        string `json:"validFromFieldName"`
	EncryptedValidFrom        string `json:"encryptedValidFrom"`
}

KickTokenProviderReply is a reply to a token request.

type LinkV1

type LinkV1 struct {
	ID          uint64    `json:"id"`
	ChannelID   uint64    `json:"channel_id"`
	Description string    `json:"description"`
	Link        string    `json:"link"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Order       uint64    `json:"order"`
	Title       string    `json:"title"`
}

LinkV1 is a representation of a link in API v1.

type LivestreamV1

type LivestreamV1 struct {
	ID            uint64 `json:"id"`
	Slug          string `json:"slug"`
	ChannelID     uint64 `json:"channel_id"`
	CreatedAt     string `json:"created_at"`
	SessionTitle  string `json:"session_title"`
	IsLive        bool   `json:"is_live"`
	RiskLevelID   any    `json:"risk_level_id"`
	StartTime     string `json:"start_time"`
	Source        any    `json:"source"`
	TwitchChannel any    `json:"twitch_channel"`
	Duration      uint64 `json:"duration"`
	Language      string `json:"language"`
	IsMature      bool   `json:"is_mature"`
	ViewerCount   uint64 `json:"viewer_count"`
	Thumbnail     struct {
		Src    string `json:"src"`
		Srcset string `json:"srcset"`
	} `json:"thumbnail"`
	Views      uint64       `json:"views"`
	Tags       []any        `json:"tags"`
	Categories []CategoryV1 `json:"categories"`
	Video      VideoV1      `json:"video"`
}

LivestreamV1 is a representation of a live stream in API v1.

type LivestreamV2

type LivestreamV2 struct {
	ID           int        `json:"id"`
	Slug         string     `json:"slug"`
	SessionTitle string     `json:"session_title"`
	CreatedAt    time.Time  `json:"created_at"`
	Language     string     `json:"language"`
	IsMature     bool       `json:"is_mature"`
	Viewers      int        `json:"viewers"`
	Category     CategoryV2 `json:"category"`
	PlaybackURL  string     `json:"playback_url"`
	Thumbnail    struct {
		Src    string `json:"src"`
		Srcset string `json:"srcset"`
	} `json:"thumbnail"`
}

LivestreamV2 represents a live stream in API v2.

type LivestreamV2Reply

type LivestreamV2Reply struct {
	Data *LivestreamV2 `json:"data"`
}

LivestreamV2Reply is the response provided by GetLivestreamV2

type MediaAssetV1

type MediaAssetV1 struct {
	ID               uint64 `json:"id"`
	ModelType        string `json:"model_type"`
	ModelID          uint64 `json:"model_id"`
	CollectionName   string `json:"collection_name"`
	Name             string `json:"name"`
	FileName         string `json:"file_name"`
	MimeType         string `json:"mime_type"`
	Disk             string `json:"disk"`
	Size             uint64 `json:"size"`
	Manipulations    []any  `json:"manipulations"`
	CustomProperties struct {
		GeneratedConversions struct {
			Fullsize bool `json:"fullsize"`
		} `json:"generated_conversions"`
	} `json:"custom_properties"`
	/*ResponsiveImages struct {
		Fullsize struct {
			Urls      []string `json:"urls"`
			Base64Svg string   `json:"base64svg"`
		} `json:"fullsize"`
	} `json:"responsive_images"`*/
	OrderColumn     uint64    `json:"order_column"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	UUID            string    `json:"uuid"`
	ConversionsDisk string    `json:"conversions_disk"`
}

MediaAssetV1 is a representation of a media asset in API v1.

type MobileLoginReply

type MobileLoginReply struct {
	TwoFARequired bool `json:"2fa_required"`
}

MobileLoginReply is a reply to mobile logging in request.

type MobileLoginRequest

type MobileLoginRequest struct {
	Email              string `json:"email"`
	Password           string `json:"password"`
	OneTimePassword    string `json:"one_time_password"`
	KickTokenX         string `json:"_kick_token_xxxxxxxxxx"` // ?
	KickTokenValidFrom string `json:"_kick_token_valid_from"`
	IsMobileRequest    bool   `json:"isMobileRequest"`
}

MobileLoginRequest is a request for mobile logging in.

type Route

type Route string

Route is a selector of a specific endpoint.

type RouteVars

type RouteVars map[string]any

RouteVars are the substitutions in an URI defined in ./resources/endpoints.json.

type SubscriberBadgeV1

type SubscriberBadgeV1 struct {
	ID         uint64  `json:"id"`
	ChannelID  uint64  `json:"channel_id"`
	Months     uint64  `json:"months"`
	BadgeImage ImageV1 `json:"badge_image"`
}

SubscriberBadgeV1 is a representation of a subscriber badge in API v1.

type UserV1

type UserV1 struct {
	ID              uint64    `json:"id"`
	Username        string    `json:"username"`
	AgreedToTerms   bool      `json:"agreed_to_terms"`
	EmailVerifiedAt time.Time `json:"email_verified_at"`
	Bio             string    `json:"bio"`
	Country         string    `json:"country"`
	State           string    `json:"state"`
	City            string    `json:"city"`
	Instagram       string    `json:"instagram"`
	Twitter         string    `json:"twitter"`
	Youtube         string    `json:"youtube"`
	Discord         string    `json:"discord"`
	Tiktok          string    `json:"tiktok"`
	Facebook        string    `json:"facebook"`
	ProfilePic      string    `json:"profile_pic"`
}

UserV1 is a representation of an user in API v1.

type VideoV1

type VideoV1 struct {
	ID                uint64    `json:"id"`
	LiveStreamID      uint64    `json:"live_stream_id"`
	Slug              any       `json:"slug"`
	Thumb             any       `json:"thumb"`
	S3                any       `json:"s3"`
	TradingPlatformID any       `json:"trading_platform_id"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
	UUID              string    `json:"uuid"`
	Views             uint64    `json:"views"`
	DeletedAt         any       `json:"deleted_at"`
}

VideoV1 is a representation of a VOD in API v1.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL