# @collabland/sdk

SDK for CollabLand APIs - https://api.collab.land.

## Install dependencies

By default, dependencies were installed when this application was generated.
Whenever dependencies in `package.json` are changed, run the following command:

```sh
npm install
```

To only install resolved dependencies in `package-lock.json`:

```sh
npm ci
```

## Try it out

1. Get an oAuth2 access token from Discord

2. For Node.js, run the following command:

```sh
npm run build
node dist/examples/get-user <discord-oauth2-access-token>
```

3. For browsers, open index.html

## Use it in browsers

```html
<!doctype html>
<html>
  <head>
    <title>CollabLand SDK Demo</title>
    <script src="https://unpkg.com/@collabland/sdk" charset="utf-8"></script>
    <script>
      async function main() {
        const accessToken = document.getElementById('token').value;
        const client = new collabland.CollabLandClient(accessToken);
        await client.connect();
        try {
          const user = await client.account.getUserProfile();
          alert(JSON.stringify(user));
        } catch (err) {
          alert(err);
        }
      }
    </script>
  </head>

  <body>
    <h1>CollabLand SDK Demo</h1>
    <form>
      <label for="token">Discord oAuth2 Token:</label><br />
      <input type="password" id="token" name="accessToken" />
      <p>
        <input type="button" onClick="main()" value="Submit" />
      </p>
    </form>
  </body>
</html>
```

## Rebuild the project

To incrementally build the project:

```sh
npm run build
```

To force a full build by cleaning up cached artifacts:

```sh
npm run rebuild
```

## Fix code style and formatting issues

```sh
npm run lint
```

To automatically fix such issues:

```sh
npm run lint:fix
```
