Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions payloads/v1/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {Emote} from './emote';
import type {EventChannelReward} from './rewards';

/**
* @see {@link https://docs.kick.com/events/event-types}
Expand All @@ -9,6 +10,7 @@ export type EventNames
| 'channel.subscription.renewal'
| 'channel.subscription.gifts'
| 'channel.subscription.new'
| 'channel.reward.redemption.updated'
| 'livestream.status.updated'
| 'livestream.metadata.updated'
| 'moderation.banned'
Expand Down Expand Up @@ -133,6 +135,18 @@ export interface NewSubscriptionEvent {
expires_at: string;
}

export interface ChannelRewardRedemptionEvent {
eventType: 'channel.reward.redemption.updated';
eventVersion: '1';
id: string;
user_input: string;
status: 'pending' | 'accepted' | 'rejected';
redeemed_at: string;
reward: EventChannelReward;
redeemer: EventBaseUser;
broadcaster: EventBaseUser;
}

export interface LivestreamStatusUpdatedEvent {
eventType: 'livestream.status.updated';
eventVersion: '1';
Expand Down
1 change: 1 addition & 0 deletions payloads/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './emote';
export * from './events';
export * from './livestream';
export * from './oauth2';
export * from './rewards';
export * from './users';
26 changes: 26 additions & 0 deletions payloads/v1/rewards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Reward information in webhook events
* NOTE: This is a simplified version of ChannelReward without some fields
* that are not provided in event payloads.
*/
export interface EventChannelReward {
/**
* Unique identifier for the reward (ULID format)
*/
id: string;

/**
* Display name of the reward
*/
title: string;

/**
* Cost of the reward in channel points
*/
cost: number;

/**
* Description of the reward
*/
description: string;
}
19 changes: 19 additions & 0 deletions rest/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './livestreams';
export * from './moderation';
export * from './oauth2';
export * from './public-key';
export * from './rewards';
export * from './users';

export const APIVersion = 'v1';
Expand Down Expand Up @@ -107,4 +108,22 @@ export const Routes = {
EventsSubscriptions() {
return `/events/subscriptions` as const;
},

/**
* Route for:
* - GET `/channels/rewards`
* - POST `/channels/rewards`
*/
ChannelsRewards() {
return `/channels/rewards` as const;
},

/**
* Route for:
* - PATCH `/channels/rewards/{id}`
* - DELETE `/channels/rewards/{id}`
*/
ChannelsReward(id: string) {
return `/channels/rewards/${id}` as const;
},
};
166 changes: 166 additions & 0 deletions rest/v1/rewards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import type {RESTResult} from './global';

/**
* A Kick channel reward
*
* @see {@link https://docs.kick.com/apis/channel-rewards}
*/
export interface ChannelReward {
/**
* Unique identifier for the reward (ULID format)
*/
id: string;

/**
* Display name of the reward (max 50 characters)
*/
title: string;

/**
* Description of the reward (max 200 characters)
*/
description: string;

/**
* Cost of the reward in channel points
*/
cost: number;

/**
* Hex color code for the reward background
*/
background_color: string;

/**
* Whether this reward is enabled
*/
is_enabled: boolean;

/**
* Whether this reward requires user input
*/
is_user_input_required: boolean;

/**
* Whether redemptions of this reward should skip the request queue
*/
should_redemptions_skip_request_queue: boolean;
}

/**
* Request body for creating a channel reward
*
* @see {@link https://docs.kick.com/apis/channel-rewards#post-channels-rewards}
*/
export interface ChannelRewardCreateRequest {
/**
* Display name of the reward (required, max 50 characters)
*/
title: string;

/**
* Cost of the reward in channel points (required, min 1)
*/
cost: number;

/**
* Description of the reward (optional, max 200 characters)
*/
description?: string;

/**
* Hex color code for the reward background (optional, default #00e701)
*/
background_color?: string;

/**
* Whether this reward is enabled (optional, default true)
*/
is_enabled?: boolean;

/**
* Whether this reward requires user input (optional, default false)
*/
is_user_input_required?: boolean;

/**
* Whether redemptions of this reward should skip the request queue (optional, default false)
*/
should_redemptions_skip_request_queue?: boolean;
}

/**
* Request body for updating a channel reward
*
* All fields are optional
*
* @see {@link https://docs.kick.com/apis/channel-rewards#patch-channels-rewards-id}
*/
export interface ChannelRewardUpdateRequest {
/**
* Display name of the reward (max 50 characters)
*/
title?: string;

/**
* Cost of the reward in channel points (min 1)
*/
cost?: number;

/**
* Description of the reward (max 200 characters)
*/
description?: string;

/**
* Hex color code for the reward background
*/
background_color?: string;

/**
* Whether this reward is enabled
*/
is_enabled?: boolean;

/**
* Whether this reward requires user input
*/
is_user_input_required?: boolean;

/**
* Whether redemptions of this reward should skip the request queue
*/
should_redemptions_skip_request_queue?: boolean;
}

/**
* Response from getting channel rewards
*
* @see {@link https://docs.kick.com/apis/channel-rewards#get-channels-rewards}
*/
export type RESTGetChannelRewardsResult = RESTResult<ChannelReward[]>;

/**
* Response from creating a channel reward
*
* @see {@link https://docs.kick.com/apis/channel-rewards#post-channels-rewards}
*/
export type RESTCreateChannelRewardResult = RESTResult<ChannelReward>;

/**
* Response from updating a channel reward
*
* Returns 204 No Content on success
*
* @see {@link https://docs.kick.com/apis/channel-rewards#patch-channels-rewards-id}
*/
export type RESTUpdateChannelRewardResult = never;

/**
* Response from deleting a channel reward
*
* Returns 204 No Content on success
*
* @see {@link https://docs.kick.com/apis/channel-rewards#delete-channels-rewards-id}
*/
export type RESTDeleteChannelRewardResult = never;