![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
ts-twitch-api
Advanced tools
Very simple TwitchApi class and TypeScript interfaces for all Twitch API endpoints
Very simple TwitchApi
class and TypeScript interfaces for all Twitch API endpoints
fetch
under the hoodnpm i ts-twitch-api
pnpm i ts-twitch-api
yarn add ts-twitch-api
import type {
UpdateAutoModSettingsParams,
UpdateAutoModSettingsBody,
UpdateAutoModSettingsResponse,
} from 'ts-twitch-api';
const updateAutoModSettings = async (
params: UpdateAutoModSettingsParams,
body: UpdateAutoModSettingsBody,
) => {
const searchParams = new URLSearchParams(params);
const url = `https://api.twitch.tv/helix/moderation/automod/settings?${searchParams}`;
const response = await fetch(url, {
method: 'PUT',
body: JSON.stringify(body),
headers: {
Authorization: `Bearer ${process.env.ACCESS_TOKEN}`,
'Client-Id': process.env.CLIENT_ID,
'Content-Type': 'application/json',
},
});
return response.json() as Promise<UpdateAutoModSettingsResponse>;
}
TwitchApi
classimport { TwitchApi } from 'ts-twitch-api';
const twitchApi = new TwitchApi({
accessToken: process.env.ACCESS_TOKEN,
clientId: process.env.CLIENT_ID,
});
const response = await twitchApi.chat.updateChatSettings(
// query params
{ broadcaster_id: '1', moderator_id: '2' },
// body
{ emote_mode: true },
);
if (response.ok) {
console.log(response.data);
} else {
console.error(response.status);
}
const streams = await twitchApi.streams.getStreams(
// some endpoints accept multiple ids like this: `id=1234&id=5678`
{ user_id: ['1', '2'] },
// override accessToken and/or clientId for different requests
'<accessToken>',
'<clientId>',
);
if (streams.ok) {
console.log(streams.data);
}
FAQs
Very simple TwitchApi class and TypeScript interfaces for all Twitch API endpoints
We found that ts-twitch-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.