{"id":22147450,"url":"https://github.com/megadrive/twitchonlinetracker","last_synced_at":"2026-02-26T08:43:48.932Z","repository":{"id":33873669,"uuid":"163180693","full_name":"megadrive/TwitchOnlineTracker","owner":"megadrive","description":"A TypeScript Node.JS library to track when Twitch.TV streams goes up or down.","archived":false,"fork":false,"pushed_at":"2022-02-11T00:31:38.000Z","size":44,"stargazers_count":10,"open_issues_count":3,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-11-10T06:43:33.595Z","etag":null,"topics":["stream-changes","twitch","twitch-api","twitchtv"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/megadrive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-26T13:01:53.000Z","updated_at":"2024-11-03T02:28:54.000Z","dependencies_parsed_at":"2022-08-07T23:30:24.584Z","dependency_job_id":null,"html_url":"https://github.com/megadrive/TwitchOnlineTracker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megadrive%2FTwitchOnlineTracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megadrive%2FTwitchOnlineTracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megadrive%2FTwitchOnlineTracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/megadrive%2FTwitchOnlineTracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/megadrive","download_url":"https://codeload.github.com/megadrive/TwitchOnlineTracker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227642175,"owners_count":17797850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stream-changes","twitch","twitch-api","twitchtv"],"created_at":"2024-12-01T23:17:44.662Z","updated_at":"2026-02-26T08:43:48.893Z","avatar_url":"https://github.com/megadrive.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Track when Twitch streams go online\n\n## Quickstart\n\nInstall: `npm install --save twitchonlinetracker`\n\nGet a Client ID. See Step 1 of the [Twitch API Introduction](https://dev.twitch.tv/docs/api/#introduction) on how to do this.\n\n```js\nconst { TwitchOnlineTracker } = require('twitchonlinetracker')\nconst tracker = new TwitchOnlineTracker({\n  client_id: \"your twitch app client id\", // used for api requests\n  track: ['channel1', 'channel2'], // all the channels you want to track\n  pollInterval: 30, // how often in between polls in seconds. default 30\n  debug: true, // whether to debug to console\n  start: true // whether to start immediately. if you don't use this, you must call .start() later\n})\n\n// Listen to live event, it returns StreamData\ntracker.on('live', streamData =\u003e {\n  console.log(`${streamData.user_name} just went live!`)\n})\n\n// Make sure you listen for errors\ntracker.on('error', error =\u003e console.error)\n```\n\n**NOTE:** If you don't pass `start: true` in the options, you must call `tracker.start()` to start polling.\n\n## TwitchOnlineTracker API\n\n### const tracker = new TwitchOnlineTracker(options: [TwitchOnlineTrackerOptions](https://github.com/megadrive/TwitchOnlineTracker/blob/949212b7834f0df11c0309dc85559836d57f364c/src/interfaces.ts#L66-L72))\n\nCreate a new `TwitchOnlineTracker` instance. It takes a TwitchOnlineTrackerOptions interface:\n\n- `client_id` *string* **required** Your Twitch app's client id\n- `track` *string[]* An array of the channels you wish to track on startup\n- `pollInterval` *number* The amount of time in seconds between polls\n- `debug` *boolean* If true, output debug information to console\n- `start` *boolean* If true, start polling immediately\n\n### tracker.start()\n\nStarts polling the Twitch API for stream changes.\n\n### tracker.stop()\n\nStops polling the Twitch API for stream changes.\n\n### tracker.track(usernamesToTrack: string[])\n\nAdds more streams to track. `usernamesToTrack` expects an array of strings.\n\n### tracker.untrack(usernamesToUntrack: string[])\n\nStops tracking streams. `usernamesToTrack` expects an array of strings.\n\n### tracker.on('live', function (streamData: [StreamData](https://github.com/megadrive/TwitchOnlineTracker/blob/12505f0bfe16129d4a125c93a021c41510db452c/src/interfaces.ts#L36-L48)) { })\n\nWhen a stream is found to be live, fires this event. The callback function provides a StreamData parameter.\n\nExample:\n```javascript\ntracker.on('live', function (streamData) {\n  console.log(`${streamData.user_name} has started streaming with the title ${streamData.title} at https://twitch.tv/${streamData.user_name} for ${streamData.viewer_count} viewers!`)\n})\n```\n\n### tracker.on('offline', function (channelName: string) { })\n\nWhen a stream is found to have gone offline, fires this event. The callback function provides a string.\n\nExample:\n```javascript\ntracker.on('offline', function (channel) {\n  console.log(`${channel} has gone offline.`)\n})\n```\n\n### tracker.on('error', function (error) { })\n\nFires this event on error. Make sure you capture this event.\n\nExample:\n```javascript\ntracker.on('error', function (error) {\n  throw Error(error)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegadrive%2Ftwitchonlinetracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegadrive%2Ftwitchonlinetracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegadrive%2Ftwitchonlinetracker/lists"}