# spelunky2

> Unofficial Spelunky 2 API

Latest version **0.0.1** (published 2024-01-31) · 0 weekly downloads

## Install

```sh
npm install spelunky2
pnpm add spelunky2
yarn add spelunky2
bun add spelunky2
```

## 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.0.1 |
| Published | 2024-01-31 |
| First published | 2024-01-31 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 35.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fienestar |

## Links

- npm: https://www.npmjs.com/package/spelunky2
- Homepage: https://github.com/fienestar/spelunky2-api#readme
- Issues: https://github.com/fienestar/spelunky2-api/issues
- npm.io page: https://npm.io/package/spelunky2

## Dependencies (1)

- [zstddec](https://npm.io/package/zstddec.md) ^0.1.0

## Recent versions

- 0.0.1 (latest) — 2024-01-31

## README

# Spelunky 2 API

Unofficial Spelunky 2 API

## Installation

```bash
npm i spelunky2
```

## Features

- create online lobby
- join online lobby
- fetch leaderboard

## Usage

```ts
import { GameMode, Platform, PlayerCharacter, ReadyState, Spelunky2Client } from 'spelunky2';

const client = new Spelunky2Client;

async function main() {
    const player = {
        platform: Platform.NONE,
        id: 0x7777777777777777n,
        name: 'Player 1',
        gameMode: GameMode.CO_OP,
        character: PlayerCharacter.YELLOW,
        readyState: ReadyState.NOT_READY,
    };
    const lobby1 = await client.createOnlineLobby(player);
    console.log('created lobby code: ' + lobby1.code);

    player.name = 'Player 2';
    
    const lobby2 = await client.joinOnlineLobby(lobby1.code, player);
    console.log('joined lobby code: ' + lobby2.code)
    console.log('players');
    for(const player of lobby2.players) {
        if(player === null) console.log('  ㄴ(empty slot)')
        else console.log('  ㄴ' + player.name);
    }

    lobby1.detach();
    lobby2.detach();

    const leaderboard = await client.getLeaderboard(2024, 1, 31);
    let max_score = leaderboard[0].score;
    for(const entry of leaderboard) {
        if(entry.score > max_score) max_score = entry.score;
    }
    console.log('max score at 2024/01/31 is : ' + max_score);
}

main()
    .catch((err) => {
        console.error(err);
    });

/*
output:
created lobby code: A70C1F7F(example)
joined lobby code: A70C1F7F
players
  ㄴPlayer 1
  ㄴPlayer 2
  ㄴ(empty slot)
  ㄴ(empty slot)
max score at 2024/01/31 is : 1412945
*/
```

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