
# Unofficial Playit.GG API Module

This module is built for personal use within my own apps or features. I have made it public so others can contribute or find bugs and help fix them. This is also one of my first open source projects as I am usually very protective over the code. Below you can find the [docs](#docs) of this module and how to use it.

# Docs
## Module Installation
You can install `playit-api` by running: `npm i playit-api`.

## Logging in
You may want to know how to log in. Here you can find out how.

```typescript
import { PlayitClient } from  'playit-api'

const  client = new  PlayitClient();

client.login({

email: 'my-email@gmail.com', // Your email on Playit.GG

password: 'pas$w0rd',        // Your password on Plait.GG

code: "000000"               // Six digit 2FA code (only include if you have 2FA on)


});
```

## Events
Playit-api has a few events you can listen to. These are listed below and their descriptions.

| Event Name    | Event parameters | Usage|
| :-------------: |:-------------:| :-----:|
| login         |                 | Can be called when logging in to console log or trigger fetching other data |
| ready      | user|   Params return the current user object, and can be used to console log who logged in, or make sure you are on the right account. |


## Other API Calls
These include fetching tunnels, user data, or other information from the logged in user.
```typescript
client.listAgents().then((agents) => {

    // do something with your list of agents?

});
client.listTunnels(someAgentIdString).then((tunnels) => {

   // also do something with tunnels list?

});
```
