---
# System prepended metadata

title: Singleplayer API

---

# Singleplayer API

### Connecting with the websocket

``` shell
  wss://localhost:3000/ws?session={{session}}
```

### Start:

The game will start with or without a bet. The player will receive a response with the current step and multiplier.
If the game is started, the player will not be able to make a bet until the game is finished.

If the game starts with a bet, the player will receive a response with the current step and multiplier, and the bet will
be placed.

#### Start payload:

```json
{
  "messageType": "start"
}
```

#### Response example:

```json
{
  "crash": false,
  "step": 117,
  "multiplier": 124,
  "denominator": 2
}
```

#### end of the round

```json
{
  "MessageType": "crash",
  "ProvablyFair": {
    "hash": "823a40f2f63cf8202809a0e3cc3935f502c69ed2ca00845ce8600555eb5e6c66",
    "salt": "097f8caa-a8f4-47d4-b0a2-cc1598bab502bb93fbe9-0e0d-41f2-8e04-b3601b9437a4",
    "previousResult": 155,
    "currentResult": 321
  }
}
```

### Speedup:

The server sends this message when the game enters the fast phase (after 6 steps).

#### Response example:

```json
{
  "messageType": "speedup",
  "walkDuration": 100,
  "fightDuration": 100
}
```


### Bet:

```json
{
  "messageType": "bet",
  "identifier": 1,
  "amount": 100,
  "currency": "EUR"
}
```

#### Response example:

```json
{
  "messageType": "bet",
  "username": "Guest **",
  "balance": 99700,
  "denominator": 100,
  "identifier": 1,
  "currency": "USD",
  "betID": "0e4cf975-63d9-490c-b021-d3fcd3659765",
  "isDemo": true
}
```

### Wallet:

```json
{
  "messageType": "wallet"
}
```

#### Response example:

```json
{
  "messageType": "wallet",
  "username": "Guest **98138",
  "balance": 101181,
  "denominator": 10000,
  "currency": "ADA",
  "isDemo": true,
  "isGameOngoing": false,
  "multiplierHistory": null,
  "bonusHistory": null,
  "provablyFair": {
    "hash": "609cf86c4037abf9e3301f199cb8c4ec42b5796dd7056d0013172991cad63a4a",
    "salt": null,
    "previousResult": 5311,
    "currentResult": null
  },
  "maxBet": 273000,
  "minBet": 273,
  "defaultBet": 10000,
  "rtp": "95",
  "volatility": "high",
  "shortcuts": [
    "1"
  ],
  "fightDuration": 200,
  "walkDuration": 200,
  "currentBets": [
    {
      "betId": "3eb1550d-23bb-4fe3-adb9-5fa825ebe5a5",
      "amount": 3333,
      "identifier": 2
    },
    {
      "betId": "c683db2e-649d-48b0-84a2-d6d125f0990e",
      "amount": 333,
      "identifier": 1,
      "autoCashoutAt": 232
    }
  ],
  "limitValues": {
    "minMultiplier": 1,
    "maxMultiplier": 1750,
    "minCrashPoint": 100,
    "MaxCrashPoint": 1750000
  }
}
```

### CheckWin:

Players can checkWin at any time after the game start. The player will receive a response with the current multiplier
and the amount that can be cashed out.

```json
{
  "messageType": "win",
  "betID": "550e8400-e29b-41d4-a716-446655440000",
  "cashoutAt": 150
}
```

#### Response example:

```json
{
  "messageType": "cashOutResult",
  "username": "player123",
  "balance": 12000,
  "denominator": 2,
  "currency": "USD"
}
```

### BetCancel:

Players can can cancel a bet at any time before the game starts. The player will receive a response with the current
balance.

```json
{
  "messageType": "bet_cancel",
  "betID": "9d7da6bd-90f1-4eff-85e1-a5b177016e02"
}
```

#### Response example:

```json
{
  "messageType": "bet_cancel",
  "betID": "9d7da6bd-90f1-4eff-85e1-a5b177016e02",
  "username": "player123",
  "balance": 9500,
  "denominator": 2,
  "currency": "USD"
}
```

### Bet history:

Players can can cancel a bet at any time before the game starts. The player will receive a response with the current
balance.

```json
{
  "messageType": "bet_history"
}
```

#### Response example:

```json
{
  "messageType": "bet_history",
  "username": "Guest **oduyp",
  "history": [
    {
      "betID": "c46330a0-e63b-4f31-9f96-1e2c0e49ec03",
      "createdAt": "2025-11-25 15:40:06",
      "amount": 100,
      "winAmount": 0,
      "denominator": 100,
      "currency": "BRL",
      "isActive": false,
      "isDemo": false,
      "roundStart": "2025-11-28 14:54:58",
      "provablyFair": {
        "hash": "a96635c72613f54e8c5d",
        "salt": "44de-9a22-f66b831712c5",
        "previousResult": 110,
        "currentResult": 177
      }
    }
  ]
}
```

# Game Error Documentation

## Error Codes Overview

| Code | Message                                 |
|------|-----------------------------------------|
| 1000 | SessionID expired or not found          |
| 1001 | Bet does not respect minimum bet amount |
| 1002 | Bet does not respect maximum bet amount |
| 1003 | Bet not found                           |
| 1004 | Bet already placed                      |
| 1005 | Bet could not be placed                 |
| 1006 | Bet could not be canceled               |
| 1007 | Bet could not be cashed out             |
| 1008 | Minimum auto cashout value is not valid |
| 1009 | Game already started                    |
| 1010 | Game not finished                       |
| 1011 | Game crashed                            |
| 1012 | Ongoing game not found                  |
| 1013 | Invalid message type                    |
| 1014 | Invalid identifier for bet cancelation  |
| 1015 | Invalid time format                     |
| 1016 | No bets placed                          |

## Common Message Types

These message types are used across both game modes:

- `wallet` - Balance operations
- `bet` - Bet placement
- `bet_cancel` - Bet cancellation
- `win` - Win notifications
- `bet_history` - Game history

## Error Response Format

```json
{
  "messageType": "errorResponse",
  "error": {
    "message": "Invalid bet amount",
    "code": 400,
    "var": 100
  }
}
```
