> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sammwyy/mikuMikuBeam/llms.txt
> Use this file to discover all available pages before exploring further.

# Server API Overview

> Connect to the Miku Miku Beam server via HTTP REST and Socket.IO

## Introduction

The Miku Miku Beam server exposes both REST endpoints and real-time Socket.IO connections for managing network stress tests. The server is built with Echo framework and supports CORS for web client integration.

## Base Configuration

The server listens on the port configured in your settings (default: 8080).

```
Base URL: http://localhost:8080
Socket.IO: ws://localhost:8080/socket.io/
```

## Authentication

Currently, the server does not require authentication. CORS is configured to allow requests from the origin specified in your configuration file.

## Available Endpoints

### REST Endpoints

<CardGroup cols={2}>
  <Card title="GET /attacks" icon="list" href="/api/attacks">
    List all available attack methods
  </Card>

  <Card title="GET /configuration" icon="gear" href="/api/configuration">
    Retrieve current proxy and user agent configuration
  </Card>

  <Card title="POST /configuration" icon="upload" href="/api/configuration">
    Update proxy and user agent configuration
  </Card>
</CardGroup>

### Socket.IO Events

The server uses Socket.IO for real-time attack management and statistics.

#### Client Events (Emit)

| Event         | Description                                          |
| ------------- | ---------------------------------------------------- |
| `startAttack` | Initiate a new stress test with specified parameters |
| `stopAttack`  | Stop the currently running attack                    |
| `disconnect`  | Disconnect from server (automatically stops attack)  |

#### Server Events (Listen)

| Event            | Description                                                     |
| ---------------- | --------------------------------------------------------------- |
| `stats`          | Real-time statistics updates (packets/sec, total packets, logs) |
| `attackAccepted` | Confirmation that attack has started                            |
| `attackError`    | Error message if attack cannot start                            |
| `attackEnd`      | Notification that attack has ended                              |

## Attack Methods

The following attack methods are registered by default:

* `http_flood` - Standard HTTP flood attack
* `http_bypass` - HTTP flood with bypass techniques
* `http_slowloris` - Slowloris connection exhaustion attack
* `tcp_flood` - Raw TCP packet flood
* `minecraft_ping` - Minecraft server ping flood

## Proxy Support

The server supports proxy rotation for attacks. By default, proxies are required unless you:

* Set `ALLOW_NO_PROXY=true` environment variable
* Start server with `--no-proxy` flag

<Warning>
  Running attacks without proxies exposes your IP address to the target server.
</Warning>

## Example: Basic Connection

```javascript theme={null}
import { io } from 'socket.io-client';

const socket = io('http://localhost:8080');

socket.on('connect', () => {
  console.log('Connected to Miku Miku Beam server');
});

socket.on('stats', (data) => {
  console.log('Stats:', data);
});
```

## Error Handling

### HTTP Errors

REST endpoints return standard HTTP status codes:

* `200 OK` - Request successful
* `400 Bad Request` - Invalid request parameters
* `500 Internal Server Error` - Server error

### Socket.IO Errors

Errors during attack execution are sent via the `attackError` event:

```javascript theme={null}
socket.on('attackError', (error) => {
  console.error('Attack error:', error.message);
});
```

Common error scenarios:

* No proxies available (when `ALLOW_NO_PROXY` is false)
* Invalid attack method
* Invalid target format
* Attack duration or size limits exceeded
