# greengame-api-client

> A REST API client for the GreenGame laboratory project.

Latest version **0.2.0** (published 2024-01-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install greengame-api-client
pnpm add greengame-api-client
yarn add greengame-api-client
bun add greengame-api-client
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-01-05 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jkazimierczak |
| Maintainers | jkazimierczak |

## Links

- npm: https://www.npmjs.com/package/greengame-api-client
- npm.io page: https://npm.io/package/greengame-api-client

## Recent versions

- 0.2.0 (latest) — 2024-01-05
- 0.1.3 — 2023-12-13
- 0.1.2 — 2023-12-13
- 0.1.1 — 2023-12-13
- 0.1.0 — 2023-12-12
- 0.0.8 — 2023-12-12
- 0.0.7 — 2023-12-12
- 0.0.6 — 2023-12-12
- 0.0.5 — 2023-12-12
- 0.0.4 — 2023-12-12
- 0.0.3 — 2023-12-12
- 0.0.2 — 2023-12-12

## README

# io-api-client

A REST API client for the GreenGame laboratory project.

# Installation

This library is written as ESM module. To use it your project needs to use ESM modules too.
First of all you have to set your script tag type to module:

```html
<script type="module" src="main.js"></script>
```

Then you can import the client in your main.js file:

```js
import {getUserData, updateRanking} from "https://unpkg.com/greengame-api-client@latest";
```

and use the functions as described below:

```js
const userData = await getUserData();
console.log(userData.username);
```

> A full example can be found in the [example](example) folder.

## Getting auto-completions and typechecking

> A full example that has auto-completions can be found in the [example](example) folder.

Above is the simplest way to use the client, but you won't get any auto-completions in your IDE.

To get auto-completions you have to setup TypeScript and install the client via npm.
The easiest way to do so it by copying files from the [example](example) folder into your project, namely:

- [package.json](example/package.json),
- [tsconfig.json](example/tsconfig.json),
- [.gitignore](example/.gitignore) (for safety reasons).

Also, the example tsconfig.json file has been configured to look for files in the src folder, so your JS files should be in the
src folder.

Then you have to install the dependencies via npm:

```bash
npm install
```

> This requires you to have npm installed. If you don't have npm installed, you can download
> it [here](https://nodejs.org/en/download/).

Then you have to add the importmap script to your html file:

```html
<script type="importmap">
{
    "imports": {
        "greengame-api-client": "https://unpkg.com/greengame-api-client@latest"
    }
}
</script>
``` 

And add your main.js below the script tag:

```html
<script src="src/main.mjs" type="module"></script>
```

This should give you auto-completions in your IDE:

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