Skip to content
← Public packages

@kody/twitch

Look up Twitch users, channels, streams, and follows, with dry-run chat and channel updates.

FollowFork

Files

AGENTS.md

110 lines · 3.8 KB · Markdown

@kody/twitch — agent notes

Human setup and intent live in README.md. This file is for agents: imports, smoke/dryRun execute snippets, and edge cases. Auth is the saved OAuth integration named twitch — never paste tokens. Do not disable live webhooks or jobs (this package declares none). No /account/secrets/new token path for this package.

Auth

ItemValue
Integrationtwitch (or twitch-<purpose> via integration)
API basehttps://api.twitch.tv/helix
Reconnecthttps://kody.codes/connect/oauth?provider=twitch
Hostsapi.twitch.tv, id.twitch.tv
HeadersAuthorization + Client-Id from the saved integration

Transport uses createAuthenticatedFetch('twitch'). Prefer named helpers, then ./request.

Import paths

ExportImport
overview / connect URL / scopeskody:@kody/twitch
smoke-testkody:@kody/twitch/smoke-test
get-mekody:@kody/twitch/get-me
get-userkody:@kody/twitch/get-user
get-channelkody:@kody/twitch/get-channel
get-streamkody:@kody/twitch/get-stream
list-followskody:@kody/twitch/list-follows
list-followerskody:@kody/twitch/list-followers
list-followed-streamskody:@kody/twitch/list-followed-streams
list-chatterskody:@kody/twitch/list-chatters
send-chat-messagekody:@kody/twitch/send-chat-message
update-channel-infokody:@kody/twitch/update-channel-info
requestkody:@kody/twitch/request

Prefer static kody:@kody/twitch/... imports from execute. Do not lead with packages.invoke. For smoke against a forked package runtime that must bind the caller's OAuth grant, a dynamic invoke of bare kody id twitch is acceptable — prefer the fork's published export once connected.

Smoke test (read-only)

Run on the forked package after connect. Does not return login, display name, or email.

import smokeTest from 'kody:@kody/twitch/smoke-test'

export default async function main() {
	return await smokeTest()
	// => { ok: true, integration: 'twitch', hasUserId: true, hasLogin: true }
}

Common snippets

import getUser from 'kody:@kody/twitch/get-user'
import getStream from 'kody:@kody/twitch/get-stream'

export default async function main() {
	const [user] = await getUser({ login: 'twitchdev' })
	const [stream] = await getStream({ login: user.login })
	return { user, stream }
}
import listFollows from 'kody:@kody/twitch/list-follows'

export default async function main() {
	return await listFollows({ limit: 20 })
}

dryRun / confirm (writes)

./send-chat-message, ./update-channel-info, and non-GET ./request never mutate Twitch when dryRun: true. A live write requires a fresh confirm: true after the user approved the exact payload.

import sendChatMessage from 'kody:@kody/twitch/send-chat-message'

export default async function main() {
	return await sendChatMessage({
		broadcasterLogin: 'twitchdev',
		message: 'Hello from Kody',
		dryRun: true,
	})
}

Edge cases / fork notes

  • Fork first; connect the caller's Twitch app. Do not treat the live @kody/twitch integration as theirs.
  • Helix GET /channels/followers returns only the follower total unless the token user is the broadcaster or a moderator and the token includes moderator:read:followers. The old GET /users/follows endpoint is gone.
  • HTTP 401: reconnect at /connect/oauth?provider=twitch.
  • HTTP 403 / missing scope: add the scope on the Twitch app, then reconnect.
  • redirect_uri must be exactly https://kody.codes/connect/oauth.
  • Never treat smoke success as permission to chat or change channel settings.
  • Keep LICENSE (MIT), ## Intent, and community-icon.svg for community listing.