npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twitcher

v1.0.7

Published

Module where you can easily access the Twitch API

Downloads

25

Readme

Installing

npm install twitcher

or

yarn add twitcher

Setup

Step 1:

Get your app information from https://dev.twitch.tv/console If you don't have an app, create one

Step 2:

Get Copy your application's CLIENT_ID and CLIENT_SECRET information

Paste the information you obtained

import Twtitcher from "twitcher"
const client = new Twitcher({
  token:"", client_id:"YOUR CLIENT ID", client_secret:"YOUR CLIENT SECRET"
});

Then run the application to get your Token information

const token = client.getToken()

Send the TOKEN you received to the client

const client = new Twitcher({
  token:"YOUR TOKEN", client_id:"YOUR CLIENT ID", client_secret:"YOUR CLIENT SECRET"
});

And u r Ready!

Functions

getToken()

Return your token information

getClip(clipURL)

Paramaters

  • ClipURL: Twitch Clip URL

Response

  • Clip Data

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let clip = await client.getClip("https://clips.twitch.tv/NimbleDeadYamBIRB-drT9My-tdEwUBsZq")
console.log(clip)

Example Response

{
  success: true,
  streamer: {
    id: '51950404',
    login: 'wtcn',
    display_name: 'wtcN',
    type: '',
    broadcaster_type: 'partner',
    description: 'for business inquiries : [email protected]',
    profile_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/28b40271-8bb1-4a27-9ad7-8e9a55e06180-profile_image-300x300.png',
    offline_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/dd103946-4760-46c0-8f4a-838df780baaf-channel_offline_image-1920x1080.jpeg',
    view_count: 0,
    created_at: '2013-11-22T07:16:15Z'
  },
  creator: {
    id: '571983883',
    login: 'gweepcreative',
    display_name: 'GweepCreative',
    type: '',
    broadcaster_type: '',
    description: 'Md. Backend Developer  //   @Discord Employee',
    profile_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/f618ba01-c0cb-45b1-930d-64a01b5568c9-profile_image-300x300.png',
    offline_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/fd7758e3-fdc6-4b28-9883-1da2fe560513-channel_offline_image-1920x1080.png',
    view_count: 0,
    created_at: '2020-08-24T06:51:19Z'
  },
  clip: {
    id: 'NimbleDeadYamBIRB-drT9My-tdEwUBsZq',
    url: 'https://clips.twitch.tv/NimbleDeadYamBIRB-drT9My-tdEwUBsZq',
    video_url: 'https://clips-media-assets2.twitch.tv/Xmupnna0_TMvrXRMFAbGag/40984345048-offset-2692.mp4',
    embed_url: 'https://clips.twitch.tv/embed?clip=NimbleDeadYamBIRB-drT9My-tdEwUBsZq',
    video_id: '',
    game_id: '516575',
    language: 'en',
    title: 'neeğğğğ?? (obbserver feritin aklıyla oynuyor)',
    view_count: 230,
    created_at: '2023-08-12T19:37:17Z',
    thumbnail_url: 'https://clips-media-assets2.twitch.tv/Xmupnna0_TMvrXRMFAbGag/40984345048-offset-2692-preview-480x272.jpg',
    duration: 28,
    vod_offset: null,
    is_featured: false
  }
}

getGameByName(game_name)

Paramaters

  • game_name(string): Twitch game name

Response

  • Game Data

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let game = await client.getGameByName("Fortnite")
console.log(game)

Example Response

{
  success: true,
  data: [
    {
      id: '33214',
      name: 'Fortnite',
      box_art_url: 'https://static-cdn.jtvnw.net/ttv-boxart/33214-{width}x{height}.jpg',
      igdb_id: '1905'
    }
  ]
}

getGameById(game_id)

Paramaters

  • game_id(Number): Twitch game id

Response

  • Game Data

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let game = await client.getGameById("509658")
console.log(game)

Example Response

{
  success: true,
  data: [
    {
      id: '509658',
      name: 'Just Chatting',
      box_art_url: 'https://static-cdn.jtvnw.net/ttv-boxart/509658-{width}x{height}.jpg',
      igdb_id: ''
    }
  ]
}

searchChannel(query)

Paramaters

  • query: Twitch channel name
  • type: String

Response

  • Channel Data (Array)

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let channels = await client.searchChannel("gweepcreative")
console.log(channels)

Example Response

[
  {
    broadcaster_language: 'tr',
    broadcaster_login: 'gweepcreative',
    display_name: 'GweepCreative',
    game_id: '516575',
    game_name: 'VALORANT',
    id: '571983883',
    is_live: false,
    tag_ids: [],
    tags: [ 'oyun', 'ghosts', 'valorant', 'espor', 'ESports', 'Türkçe' ],
    thumbnail_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/f618ba01-c0cb-45b1-930d-64a01b5568c9-profile_image-300x300.png',
    title: 'RANKED VALO',
    started_at: ''
  },
  {
    broadcaster_language: '',
    broadcaster_login: 'gweep_creative',
    display_name: 'gweep_creative',
    game_id: '0',
    game_name: '',
    id: '606695369',
    is_live: false,
    tag_ids: [],
    tags: [],
    thumbnail_url: 'https://static-cdn.jtvnw.net/user-default-pictures-uv/ce57700a-def9-11e9-842d-784f43822e80-profile_image-300x300.png',
    title: '',
    started_at: ''
  },
  {
    broadcaster_language: '',
    broadcaster_login: 'gweepcreative2',
    display_name: 'gweepcreative2',
    game_id: '0',
    game_name: '',
    id: '678460694',
    is_live: false,
    tag_ids: [],
    tags: [],
    thumbnail_url: 'https://static-cdn.jtvnw.net/user-default-pictures-uv/294c98b5-e34d-42cd-a8f0-140b72fba9b0-profile_image-300x300.png',
    title: '',
    started_at: ''
  },
  {
    broadcaster_language: '',
    broadcaster_login: 'gweepcreative22',
    display_name: 'gweepcreative22',
    game_id: '0',
    game_name: '',
    id: '720647790',
    is_live: false,
    tag_ids: [],
    tags: [],
    thumbnail_url: 'https://static-cdn.jtvnw.net/user-default-pictures-uv/75305d54-c7cc-40d1-bb9c-91fbe85943c7-profile_image-300x300.png',
    title: '',
    started_at: ''
  }
]

searchUserByName(query)

Paramaters

  • query: Twitch channel/user name
  • type: String

Response

  • Channel/User Data

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let user = await client.searchUserByName("gweepcreative")
console.log(user)

Example Response

{
  success: true,
  data: [
    {
      id: '571983883',
      login: 'gweepcreative',
      display_name: 'GweepCreative',
      type: '',
      broadcaster_type: '',
      description: 'Md. Backend Developer  //   @Discord Employee',
      profile_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/f618ba01-c0cb-45b1-930d-64a01b5568c9-profile_image-300x300.png',
      offline_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/fd7758e3-fdc6-4b28-9883-1da2fe560513-channel_offline_image-1920x1080.png',
      view_count: 0,
      created_at: '2020-08-24T06:51:19Z'
    }
  ]
}

searchUserByUserId(query)

Paramaters

  • query: Twitch channel/user id
  • type: String

Response

  • Channel/User Data

Example Usage

import Twitcher from "twitcher"
let client = new Twitcher({
    token:"YOUR TOKEN",
    client_id:"YOUR CLIENT ID",
})
let user = await client.searchUserByUserId("571983883")
console.log(user)

Example Response

{
  success: true,
  data: [
    {
      id: '571983883',
      login: 'gweepcreative',
      display_name: 'GweepCreative',
      type: '',
      broadcaster_type: '',
      description: 'Md. Backend Developer  //   @Discord Employee',
      profile_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/f618ba01-c0cb-45b1-930d-64a01b5568c9-profile_image-300x300.png',
      offline_image_url: 'https://static-cdn.jtvnw.net/jtv_user_pictures/fd7758e3-fdc6-4b28-9883-1da2fe560513-channel_offline_image-1920x1080.png',
      view_count: 0,
      created_at: '2020-08-24T06:51:19Z'
    }
  ]
}