Documentation
¶
Index ¶
- Constants
- Variables
- func MightError(resp Response) error
- func Ptr[T any](v T) *T
- type AuthorityKind
- type Category
- type CategoryService
- type Channel
- type ChannelService
- func (s *ChannelService) Followers(ctx context.Context, page, size *int) ([]Follower, int, error)
- func (s *ChannelService) Get(ctx context.Context, ids ...string) ([]Channel, error)
- func (s *ChannelService) Managers(ctx context.Context) ([]Manager, error)
- func (s *ChannelService) Subscribers(ctx context.Context, page, size *int, sort *SubscriptionSort) ([]Subscriber, int, error)
- type ChatAvailableKind
- type ChatBlindMessageReq
- type ChatFollowerSetting
- type ChatNoticeReq
- type ChatService
- func (s *ChatService) BlindMessage(ctx context.Context, req ChatBlindMessageReq) error
- func (s *ChatService) Notice(ctx context.Context, req ChatNoticeReq) error
- func (s *ChatService) Send(ctx context.Context, msg string) (string, error)
- func (s *ChatService) Settings(ctx context.Context) (*ChatSettings, error)
- func (s *ChatService) UpdateSettings(ctx context.Context, req ChatSettings) error
- type ChatSettings
- type Client
- type Follower
- type GrantType
- type Live
- type LiveService
- func (s *LiveService) Get(ctx context.Context, size *int, next *string) ([]Live, string, error)
- func (s *LiveService) Key(ctx context.Context) (string, error)
- func (s *LiveService) PatchSetting(ctx context.Context, p *PatchLiveSettingRequest) error
- func (s *LiveService) Setting(ctx context.Context) (*LiveSetting, error)
- type LiveSetting
- type Manager
- type NoticeKind
- type PatchLiveSettingRequest
- type Response
- type RevokeTokenRequest
- type SessionService
- type Subscriber
- type SubscriptionSort
- type TokenNewRequest
- type TokenRefreshRequest
- type TokenRequest
- type TokenResponse
- type TokenService
- type User
- type UserService
Constants ¶
const ( NoticeMessage NoticeKind = "message" NoticeMessageID NoticeKind = "messageId" ChatAvailableForAll ChatAvailableKind = "all" ChatAvailableForFollower ChatAvailableKind = "follower" ChatAvailableForManager ChatAvailableKind = "manager" ChatAvailableForSubscriber ChatAvailableKind = "subscriber" AuthorityModeAll AuthorityKind = "all" AuthorityModelRealName AuthorityKind = "realName" )
const ( Version = "0.5.0" BaseURL = "https://openapi.chzzk.naver.com" OpenV1 = "/open/v1" AuthV1 = "/auth/v1" ContentType = "application/json" UserAgent = "chzzk-go/" + Version )
Variables ¶
var ErrInvalidNoticeKind = errors.New("chzzk: invalid notice kind")
Functions ¶
func MightError ¶ added in v0.4.0
MightError checks the response body for inspecting error from the server.
The Chzzk API does not return HTTP error. Rather, it always embeds the Response field in the response body, which contains the error code and message.
Types ¶
type AuthorityKind ¶ added in v0.5.0
type AuthorityKind string
type CategoryService ¶ added in v0.3.0
type CategoryService struct {
// contains filtered or unexported fields
}
CategoryService serves an API for searching broadcast categories such as:
- games
- sports
- music
- news
- just chatting.
func (*CategoryService) Search ¶ added in v0.3.0
Search retrieves a list of categories matching the given query string.
- pattern: List
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/category#undefined
type ChannelService ¶ added in v0.2.0
type ChannelService struct {
// contains filtered or unexported fields
}
func (*ChannelService) Followers ¶ added in v0.2.0
Followers retrieves the list of followers for a channel with pagination support.
- pattern: List
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/channel#undefined-2
func (*ChannelService) Get ¶ added in v0.3.0
Get retrieves information for multiple channels by their IDs.
- pattern: BatchGet
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/channel#undefined
func (*ChannelService) Managers ¶ added in v0.2.0
func (s *ChannelService) Managers(ctx context.Context) ([]Manager, error)
Managers retrieves the list of managers for a channel. Unlike the original List operation, this API does not require pagination, as it returns all managers in a single response.
- pattern: List
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/channel#undefined-1
func (*ChannelService) Subscribers ¶ added in v0.2.0
func (s *ChannelService) Subscribers(ctx context.Context, page, size *int, sort *SubscriptionSort) ([]Subscriber, int, error)
Subscribers retrieves the list of subscribers for a channel with pagination support.
- pattern: List
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/channel#undefined-3
type ChatAvailableKind ¶ added in v0.5.0
type ChatAvailableKind string
type ChatBlindMessageReq ¶ added in v0.5.0
type ChatBlindMessageReq struct {
ChatChannelID string `json:"chatChannelId"`
MessageTime int64 `json:"messageTime"`
SenderChannelID string `json:"senderChannelId"`
}
ChatBlindMessageReq represents a request to blind (hide) a specific chat message.
type ChatFollowerSetting ¶ added in v0.5.0
type ChatNoticeReq ¶ added in v0.5.0
type ChatNoticeReq struct {
Kind NoticeKind
Content string
}
ChatNoticeReq represents a request to Notice API. It can be used to set a notice message or a notice message ID.
type ChatService ¶ added in v0.4.2
type ChatService struct {
// contains filtered or unexported fields
}
ChatService handles APIs prefixed with /chats
func (*ChatService) BlindMessage ¶ added in v0.5.0
func (s *ChatService) BlindMessage(ctx context.Context, req ChatBlindMessageReq) error
BlindMessage blinds (hides) a specific chat message.
- pattern: Create
- credential: Client.WithAPIKey
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/chat#undefined-4
func (*ChatService) Notice ¶ added in v0.4.2
func (s *ChatService) Notice(ctx context.Context, req ChatNoticeReq) error
Notice sets or updates the chat notice. Use NoticeMessage to set by message text, or NoticeMessageID to set by an existing message ID.
- pattern: Create
- credential: Client.WithAPIKey
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/chat#undefined-1
func (*ChatService) Send ¶ added in v0.4.2
Send sends a chat message and returns the message ID.
- pattern: Create
- credential: Client.WithAPIKey
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/chat#undefined
func (*ChatService) Settings ¶ added in v0.5.0
func (s *ChatService) Settings(ctx context.Context) (*ChatSettings, error)
Settings retrieves the current chat settings for the authenticated user's channel.
- pattern: Get
- credential: Client.WithAPIKey
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/chat#undefined-2
func (*ChatService) UpdateSettings ¶ added in v0.5.0
func (s *ChatService) UpdateSettings(ctx context.Context, req ChatSettings) error
UpdateSettings updates the chat settings for the authenticated user's channel.
- pattern: Update
- credential: Client.WithAPIKey
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/chat#undefined-3
type ChatSettings ¶ added in v0.5.0
type ChatSettings struct {
Kind ChatAvailableKind
FollowerSetting *ChatFollowerSetting
AuthorityMode *AuthorityKind
SlowModeSec *int
IsEmojiMode *bool
}
ChatSettings represents the chat settings for a channel. It is used in the Settings and UpdateSettings APIs.
type Client ¶ added in v0.4.2
type Client struct {
// The services
Token *TokenService
User *UserService
Session *SessionService
Channel *ChannelService
Category *CategoryService
Live *LiveService
Chat *ChatService
// contains filtered or unexported fields
}
func New ¶
New creates a new Chzzk client with the provided http.Client. If the provided http.Client is nil, a new http.Client will be created.
func (*Client) WithAPIKey ¶ added in v0.4.2
WithAPIKey returns a new Chzzk client with the provided API key.
func (*Client) WithClientAuth ¶ added in v0.4.2
WithClientAuth returns a new Chzzk client with the provided client ID and secret. You must either use WithClientAuth or WithAPIKey, not both. Using both will cause unexpected behavior.
Check the Chzzk API documentation to see further details: https://chzzk.gitbook.io/chzzk/chzzk-api/tips#access-token-api
func (*Client) WithHooks ¶ added in v0.4.2
WithHooks returns a new Chzzk client with the provided hooks for request and response. Do not modify (read or write req or resp) in the hooks, as it may cause unexpected behavior. The recommended way is to clone the request and response in the hooks, and modify the cloned objects. Or just log the request and response in the hooks, without modifying them.
type Live ¶ added in v0.3.0
type Live struct {
ID int `json:"liveId"`
Title string `json:"liveTitle"`
ThumbnailImageURL string `json:"liveThumbnailImageUrl"`
ViewerCount int `json:"concurrentUserCount"`
StartDate string `json:"openDate"`
IsAdult bool `json:"adult"`
Tags []string `json:"tags"`
CategoryID string `json:"liveCategory"`
CategoryType string `json:"categoryType"`
CategoryValue string `json:"liveCategoryValue"`
ChannelID string `json:"channelId"`
ChannelName string `json:"channelName"`
ChannelImageURL string `json:"channelImageUrl"`
}
type LiveService ¶ added in v0.3.0
type LiveService struct {
// contains filtered or unexported fields
}
LiveService provides methods for accessing live streaming features of the Chzzk API.
func (*LiveService) Get ¶ added in v0.3.0
Get retrieves a list of live streams sorted by viewer count, with optional pagination.
- pattern: List
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/live#undefined
func (*LiveService) Key ¶ added in v0.3.0
func (s *LiveService) Key(ctx context.Context) (string, error)
Key retrieves the live streaming key for the authenticated user. Returns empty string if the user is not currently broadcasting.
- pattern: Get
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/live#undefined-1
func (*LiveService) PatchSetting ¶ added in v0.3.0
func (s *LiveService) PatchSetting(ctx context.Context, p *PatchLiveSettingRequest) error
PatchSetting updates the live streaming settings for the authenticated user.
- pattern: Update
- credential: [Chzzk.WithAPIKey]
Example — set category (categoryType is required when categoryId is non-empty):
c.Live.PatchSetting(ctx, &chzzk.PatchLiveSettingRequest{
Category: &chzzk.Category{Type: "GAME", ID: "League_of_Legends"},
})
Example — clear category:
c.Live.PatchSetting(ctx, &chzzk.PatchLiveSettingRequest{
Category: &chzzk.Category{ID: ""},
})
Example — set title and tags:
title := "My Stream"
c.Live.PatchSetting(ctx, &chzzk.PatchLiveSettingRequest{
Title: &title,
Tags: []string{"game", "lol"},
})
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/live#undefined-3
func (*LiveService) Setting ¶ added in v0.3.0
func (s *LiveService) Setting(ctx context.Context) (*LiveSetting, error)
Setting retrieves the default live streaming settings for the authenticated user.
- pattern: Get
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/live#undefined-2
type LiveSetting ¶ added in v0.3.0
type NoticeKind ¶ added in v0.4.2
type NoticeKind string
type PatchLiveSettingRequest ¶ added in v0.3.0
type Response ¶ added in v0.2.0
Response is a struct that Chzzk always returns in the response body, with the actual response type in the Content field.
Each Service should embed Response to its own response struct, including the Content field with the actual response type.
type RevokeTokenRequest ¶
type SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
func (*SessionService) AuthClient ¶
func (s *SessionService) AuthClient(ctx context.Context) (string, error)
AuthClient returns a URL for connecting to the Chzzk session service via client credentials.
- pattern: Get
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/session#undefined
func (*SessionService) AuthUser ¶
func (s *SessionService) AuthUser(ctx context.Context) (string, error)
AuthUser returns a URL for connecting to the Chzzk session service via user credentials.
- pattern: Get
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/session#undefined-1
func (*SessionService) SubscribeChat ¶
func (s *SessionService) SubscribeChat(ctx context.Context, sk string) error
SubscribeChat subscribes to chat events for the given session key.
- pattern: Create
- credential: [Chzzk.WithClientAuth] or [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/session#undefined-5
func (*SessionService) UnSubscribeChat ¶
func (s *SessionService) UnSubscribeChat(ctx context.Context, sk string) error
UnSubscribeChat unsubscribes from chat events for the given session key.
- pattern: Delete
- credential: [Chzzk.WithClientAuth] or [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/session#undefined-6
type Subscriber ¶ added in v0.2.0
type SubscriptionSort ¶ added in v0.2.0
type SubscriptionSort string
const ( Recent SubscriptionSort = "RECENT" Longer SubscriptionSort = "LONGER" )
type TokenNewRequest ¶
type TokenNewRequest struct {
TokenRequest
Code string `json:"code"`
State string `json:"state"`
}
type TokenRefreshRequest ¶
type TokenRefreshRequest struct {
TokenRequest
RefreshToken string `json:"refreshToken"`
}
type TokenRequest ¶
type TokenResponse ¶
type TokenService ¶
type TokenService struct {
// contains filtered or unexported fields
}
func (*TokenService) New ¶ added in v0.2.0
func (s *TokenService) New(ctx context.Context, r TokenNewRequest) (*TokenResponse, error)
New requests a new access token using the provided authorization code and state.
- pattern: Create
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/authorization#access-token
func (*TokenService) Refresh ¶ added in v0.2.0
func (s *TokenService) Refresh(ctx context.Context, r TokenRefreshRequest) (*TokenResponse, error)
Refresh requests a new access token using the provided refresh token.
- pattern: Create
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/authorization#access-token-1
func (*TokenService) Revoke ¶ added in v0.2.0
func (s *TokenService) Revoke(ctx context.Context, r RevokeTokenRequest) error
Revoke revokes the provided access or refresh token.
- pattern: Delete
- credential: [Chzzk.WithClientAuth]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/authorization#access-token-2
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService handles APIs prefixed with /users
func (*UserService) Me ¶
func (s *UserService) Me(ctx context.Context) (*User, error)
Me retrieves the current user's information from the Chzzk API.
- pattern: Get
- credential: [Chzzk.WithAPIKey]
Check the documentation for more details: https://chzzk.gitbook.io/chzzk/chzzk-api/user
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
chzzk-login
command
|
|
|
collect
command
|
|
|
internal
|
|
|
package realtime provides a WebSocket client that has a full-duplex communication channel over a single TCP connection.
|
package realtime provides a WebSocket client that has a full-duplex communication channel over a single TCP connection. |
|
Package socketio provides a Go implementation of the Socket.IO v2 (Engine.IO v3) protocol.
|
Package socketio provides a Go implementation of the Socket.IO v2 (Engine.IO v3) protocol. |
|
package unofficial provides useful, but unofficial features for accessing to Chzzk.
|
package unofficial provides useful, but unofficial features for accessing to Chzzk. |


