{"id":13758533,"url":"https://github.com/Stateford/twitch-api","last_synced_at":"2025-05-10T08:30:32.759Z","repository":{"id":43351272,"uuid":"87384486","full_name":"Stateford/twitch-api","owner":"Stateford","description":"Easy node interaction with the twitch API, using promises","archived":false,"fork":false,"pushed_at":"2022-12-17T20:06:40.000Z","size":54,"stargazers_count":6,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T17:20:01.704Z","etag":null,"topics":["nodejs","twitch","twitch-api","twitchtv","twitchtv-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/twitch.tv-api","language":"JavaScript","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/Stateford.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":"2017-04-06T03:58:30.000Z","updated_at":"2024-09-28T05:35:25.000Z","dependencies_parsed_at":"2023-01-29T18:01:08.241Z","dependency_job_id":null,"html_url":"https://github.com/Stateford/twitch-api","commit_stats":null,"previous_names":["idietmoran/twitch-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stateford%2Ftwitch-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stateford%2Ftwitch-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stateford%2Ftwitch-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stateford%2Ftwitch-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stateford","download_url":"https://codeload.github.com/Stateford/twitch-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253389436,"owners_count":21900761,"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":["nodejs","twitch","twitch-api","twitchtv","twitchtv-api"],"created_at":"2024-08-03T13:00:31.879Z","updated_at":"2025-05-10T08:30:32.473Z","avatar_url":"https://github.com/Stateford.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["Python"],"readme":"# TWITCH-API\n### The twitch API v5 made easy\n\n## Twitch Class\n\n### Starting\nThe class object takes two parameters in the object, the client ID and the client secret.\nCreate the a new object with the correct parameters to use the class.\n\nThe package [dotenv](https://github.com/motdotla/dotenv) is recommended for keeping your client information secret.\n```js\nconst Twitch = require(\"twitch.tv-api\");\nconst twitch = new Twitch({\n    id: \"YOUR ID HERE\",\n    secret: \"YOUR SECRET HERE\"\n});\n```\n\n### Methods\n\n| METHOD  | DESCRIPTION |\n|:--------:|:-----------:|\n| `.getUser(user)` | Returns information about a user |\n| `.getFeaturedStreams(options*)` | Returns twitch's featured streams |\n| `.getTopStreams(options*)`      | Returns the current top streams |\n| `.getTopGames(options*)`        | Returns the top games |\n| `.getUsersByGame(game)`  |  Returns users by game |\n| `.getStreamUrl(user)`    | Returns the RTMP stream URL |\n| `.searchChannels(query, limit*, offset*)` | Returns a list of channels |\n| `.searchStreams(query, limit*, offset*)` | Returns a list of streams |\n| `.searchGames(query, live*)` | Returns a list of games |\n*Parameter is optional or has default values.\n\n### Using\n\nThe twitch api module uses promises to resolve/reject data.\n\n```js\nconst Twitch = require(\"twitch.tv-api\");\nconst twitch = new Twitch({\n    id: \"YOUR ID HERE\"\n    secret: \"YOUR SECRET HERE\"\n});\n\ntwitch.getUser(\"idietmoran\")\n    .then(data =\u003e {\n        console.log(data);\n    })\n    .catch(error =\u003e {\n        console.error(error);\n    });\n\n// making requests with optional parameters\nconst optionalParams = {game: 'StarCraft: Brood War', language: 'es'};\ntwitch.getTopStreams(optionalParams)\n    .then(data =\u003e {\n        console.log(data);\n    })\n    .catch(error =\u003e {\n        console.error(error);\n    });\n\ntwitch.getFeaturedStreams({limit: 5})\n    .then(data =\u003e {\n        console.log(data);\n    })\n    .catch(error =\u003e {\n        console.error(error);\n    });\n\n// non es6\ntwitch.getTopStreams()\n    .then(function(data) {\n        console.log(data);\n    })\n    .catch(function(error) {\n        console.error(error);\n    });\n\n// using async/await\nasync function foo() {\n    let data = await twitch.getTopStreams();\n    console.log(data);\n}\n\n// with error handling\nasync function foo() {\n    try {\n        let data = await twitch.getTopStreams();\n        console.log(data);\n    } catch(err) {\n        throw err;\n    }\n}\n```\n\n### Example\n\nHere is an example of routing the requests through a [Hapi](https://github.com/hapijs/hapi) server.\n\n```js\nrequire(\"dotenv\").config();\nconst Hapi = require('hapi');\nconst Twitch = require(\"twitch.tv-api\");\n\n\nconst server = new Hapi.Server({})\n\nconst twitch = new Twitch({\n    id: process.env.TWITCH_ID,\n    secret: process.env.TWITCH_SECRET\n});\n\nserver.connection({\n    port: process.env.PORT,\n    host: process.env.HOST,\n});\n\nserver.route({\n    method: 'GET',\n    path: '/twitch/api/game/{game}',\n    handler: (request, reply) =\u003e {\n        twitch.getUsersByGame(request.params.game)\n            .then(reply)\n            .catch(reply);\n    }\n});\n\nserver.start(err =\u003e {\n\n    if (err) {\n        throw err;\n    }\n    console.log(`Server running at: ${server.info.uri}`);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStateford%2Ftwitch-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStateford%2Ftwitch-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStateford%2Ftwitch-api/lists"}