Skip to content
mouse114514 edited this page Sep 6, 2026 · 1 revision

API Reference

中文版

Endpoints

Method Path Description
GET /api/catalog Block catalog (frontend palette)
POST /api/build Build mod DLL
POST /api/compile/project Preview generated files
POST /api/compile/register Compile register code only
GET /api/projects List all projects
POST /api/projects Create new project
GET /api/projects/{name} Load project
PUT /api/projects/{name} Save project
DELETE /api/projects/{name} Delete project
GET /api/projects/{name}/assets List project assets
POST /api/projects/{name}/assets/upload Upload sprite
DELETE /api/projects/{name}/assets/{file} Delete asset
GET /api/projects/{name}/assets/raw/{file} Get raw asset file

Details

GET /api/catalog

Returns the catalog of all available blocks.

Response:

{
  "nodes": [
    { "type": "cu_register_item", "category": "Register" },
    ...
  ]
}

POST /api/build

Build mod DLL from blueprint.

Request body: Blueprint JSON

Response:

{
  "success": true,
  "message": "Build succeeded!",
  "dllPath": "D:\\...\\builds\\MyMod\\bin\\Release\\MyMod.dll",
  "buildDir": "D:\\...\\builds\\MyMod"
}

Build process:

  1. Generate C# source files (Plugin.cs, RegisterContent.cs, EventHandlers.cs)
  2. Write to builds/{ModName}/ directory
  3. Copy project assets to Sprites/ subdirectory
  4. Run dotnet build -c Release
  5. Return build result

POST /api/compile/project

Preview files to be generated (without writing to disk).

Request body: Blueprint JSON

Response:

{
  "files": {
    "MyMod.csproj": "...",
    "Plugin.cs": "...",
    "RegisterContent.cs": "..."
  }
}

POST /api/compile/register

Compile register code only.

Request body: Blueprint JSON

Response:

{
  "registerContent": "..."
}

GET /api/projects

List all projects in the server's projects/ directory.

Response:

[
  { "name": "MyMod", "cbpFile": "D:\\...\\projects\\MyMod\\MyMod.cbp" }
]

POST /api/projects

Create a new project.

Request body:

{
  "mod": {
    "name": "MyMod",
    "id": "com.example.mymod",
    "version": "1.0.0",
    "description": "My first mod"
  }
}

Response:

{ "name": "MyMod" }

PUT /api/projects/{name}

Save project blueprint.

Request body: Blueprint JSON

DELETE /api/projects/{name}

Delete project and all its files.

GET /api/projects/{name}/assets

List project asset files.

Response:

[
  { "name": "sprite.png", "size": 12345, "uploaded": "2026-09-06T00:00:00Z" }
]

POST /api/projects/{name}/assets/upload

Upload a sprite file.

Request: multipart/form-data, field name file

Supported formats: .png, .jpg, .jpeg, .bmp

Response:

{ "assetId": "sprite.png", "name": "sprite.png", "originalName": "my sprite.png" }

DELETE /api/projects/{name}/assets/{file}

Delete specified asset file.

GET /api/projects/{name}/assets/raw/{file}

Get raw asset file (for frontend preview).


Data Models

Blueprint

interface Blueprint {
  mod: {
    name: string;
    id: string;
    version: string;
    description: string;
  };
  items: ItemEntry[];
  recipes: RecipeEntry[];
  eventHandlers: string;        // Event handler code
  eventHandlersXml: string;     // Blockly workspace XML
  assets: AssetEntry[];
}

interface ItemEntry {
  id: string;
  fullName: string;
  description: string;
  category: string;
  spriteRef?: string;
  isAdvanced?: boolean;
  useAction?: string;
  limbUseAction?: string;
  container?: ContainerProps;
  tool?: ToolProps;
  wearable?: WearableProps;
  liquidContainer?: LiquidContainerProps;
  battery?: BatteryProps;
  light?: LightProps;
  bandage?: BandageProps;
  syringe?: SyringeProps;
}

Build Output

After building, files are generated in builds/{ModName}/:

MyMod/
├── MyMod.csproj           # .NET 4.7.2 project file
├── Plugin.cs              # BepInEx plugin entry point
├── RegisterContent.cs     # Item/recipe/building/tile/liquid registration
├── EventHandlers.cs       # Harmony patches (if events used)
├── Sprites/               # Sprite resources
└── README.md              # Auto-generated documentation

Clone this wiki locally