# twitch-wrapper-ts

> Twitch API Wrapper for TypeScript in node.js environment.

Latest version **1.0.3** (published 2018-11-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install twitch-wrapper-ts
pnpm add twitch-wrapper-ts
yarn add twitch-wrapper-ts
bun add twitch-wrapper-ts
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-11-11 |
| First published | 2018-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 75.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Talha Talip Açıkgöz aka Implicit |
| Maintainers | implicit |
| Keywords | twitch, api, node, typescript |

## Links

- npm: https://www.npmjs.com/package/twitch-wrapper-ts
- Repository: https://github.com/Talha-T/Twitch.ts
- Homepage: https://github.com/Talha-T/twitch.ts#readme
- Issues: https://github.com/Talha-T/twitch.ts/issues
- npm.io page: https://npm.io/package/twitch-wrapper-ts

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^3.3.3
- [camelcase](https://npm.io/package/camelcase.md) ^4.1.0
- [web-request](https://npm.io/package/web-request.md) ^1.0.7
- [query-string](https://npm.io/package/query-string.md) ^5.0.1
- [@types/camelcase](https://npm.io/package/@types/camelcase.md) ^4.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-11-11
- 1.0.2 — 2018-10-26
- 1.0.1 — 2018-02-17
- 1.0.0 — 2018-02-17
- 0.5.1 — 2018-02-15
- 0.5.0 — 2018-01-05
- 0.4.1 — 2018-01-04
- 0.4.0 — 2018-01-03
- 0.3.7 — 2018-01-02
- 0.3.6 — 2018-01-02
- 0.3.5 — 2018-01-02
- 0.3.4 — 2018-01-02
- 0.3.3 — 2018-01-02
- 0.3.2 — 2018-01-02
- 0.3.1 — 2018-01-01
- … 4 more at https://npm.io/package/twitch-wrapper-ts/versions

## README

# twitch-wrapper-ts
#### Twitch Chat & API Wrapper for Node.js Typescript
[![NPM](https://nodei.co/npm/twitch-wrapper-ts.png)](https://nodei.co/npm/twitch-wrapper-ts/)
---

### Features:
- Very simple to use, both chat wise and API wise.
- Strongly typed API results.

[Bot Example](https://github.com/Talha-T/twitch-bot)

### Installation:
`npm install twitch-wrapper-ts`

### How to Use:
After installing the package, getting chat is as easy as this:
```js
import { Twitch, Message, ChannelUserState } from "twitch-wrapper-ts";

const twitch: Twitch = new Twitch("username", "token", "channelnames", "seperated");

twitch.connect();
twitch.on("connected", () => twitch.send("Connected!!", "somechannel"));
twitch.on("message", (message: Message, channelState: ChannelUserState) => console.log(message));
    
/*
Message {
  badges: '',
  color: '#00FF7F',
  displayName: 'kutsalouse',
  emotes: '',
  id: '325003d6-aad3-41c5-aa89-d6ee9c56efd7',
  mod: true,
  roomId: 69223356,
  subscriber: true,
  tmiSentTs: 1515006994874,
  turbo: true,
  userId: 47954587,
  userType: '',
  content: 'drop var alt tab yapma artık',
  channel: '#only35support',
  broadcaster:
   Broadcaster {
     emoteOnly: true,
     followersOnly: -1,
     mercury: true,
     r9k: true,
     rituals: true,
     roomId: 69223356,
     slow: true,
     subsOnly: true,
     broadcasterLang: '' }
}
*/
```

Strongly typed API calls (Fully documented in the Intellisense) :
```ts
import { ApiRequester } from "twitch-wrapper-ts";
const twitchApi = new TwitchApi(clientId, oauth);
const users = await twitchApi.users.get({
    login: "implicit1",
});

const followData = await twitchApi.users.follows.get({
    from_id: users.data[0].id,
});
/*
{ total: 63,
  data:
   [ { fromId: '69056964',
       toId: '30080751',
       followedAt: '2018-02-10T16:52:34Z' },
       ...
   ]
}
*/
```

Error handling:
```ts
try {
    //something
} catch (err) {
    console.log(err.response);
}
// { error: 'Service Unavailable', status: 503, message: '' }
```

### Important Notes.
- Do not include the prefix `oauth:` in your oauth password.
- If you do not have one, get it here: http://twitchapps.com/tmi/
- Including # or not in the channel does NOT matter.
- Currently you can get detailed information in IntelliSense, documententation will be added soon.
- As an exception for the clips endpoint, you have to cast your data from `IClip` as here:
```ts
const clip = await twitchApi.clips.get({
    id: "AwkwardHelplessSalamanderSwiftRage",
});
const clips = clip.data.map((clipV) => clipV as Clip);
console.log(clips[0].embedUrl);
```
- If you cannot make something work, be sure to check the summary comments for it.

### Extra Contact:
Implicit#8954 on Discord, talha6851@hotmail.com

---
_Source: https://npm.io/package/twitch-wrapper-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
