# Developer Overview
Chest provides a public API module (`Chest-API`) that allows other plugins to interact with loot tables programmatically. The API supports creating, deleting, querying, merging, and populating inventories with loot tables.
---
## Maven / Gradle
The Chest-API artifact is `gg.lode:Chest-API` (v1.0.0). Add it as a `compileOnly` dependency in your project so that Chest is not shaded into your plugin jar.
**Gradle (Kotlin DSL):**
```kotlin
compileOnly("gg.lode:Chest-API:1.0.0")
```
**Maven:**
```xml
<dependency>
<groupId>gg.lode</groupId>
<artifactId>Chest-API</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
```
Add `Chest` as a `depend` or `softdepend` in your `plugin.yml`:
```yaml
softdepend:
- Chest
```
---
## Accessing the API
The API is accessed through the static `ChestAPI` class. The API instance is available after Chest has been enabled.
```java
import gg.lode.chestapi.ChestAPI;
import gg.lode.chestapi.IChestAPI;
IChestAPI api = ChestAPI.getApi();
if (api == null) {
// Chest is not loaded
return;
}
```
---
## Common Operations
### Check if a loot table exists
```java
boolean exists = api.lootTableExists("my_table");
```
### Populate an inventory
```java
// Uses default item count (3-6 items)
api.populateInventory("my_table", someInventory);
// Merge multiple tables
api.populateInventoryFromMerged(List.of("table_a", "table_b"), someInventory, 2, 8);
```
### Get random items
```java
ItemStack single = api.getRandomItem("my_table");
List<ItemStack> multiple = api.getRandomItems("my_table", 5);
```
### Create and manage loot tables
```java
ILootTableManager manager = api.getLootTableManager();
manager.createLootTable("new_table", "My New Table");
manager.addItemToLootTable("new_table", itemStack, 10);
```
> Mutations (`addItemToLootTable`, `removeItemFromLootTable`) are automatically saved to disk. You do not need to call `saveLootTable()` after these operations.
---
## Architecture
| Module | Description |
|---|---|
| **Chest-API** | Public interfaces. Depend on this module. |
| **Chest-Paper** | Implementation. Contains commands, menus, managers, and WorldEdit integration. Do not depend on this directly. |
The API entry point is `ChestAPI.getApi()`, which returns an `IChestAPI` instance. From there, you can access the `ILootTableManager` for full loot table CRUD operations.
---
## Related Pages
- [[Chest/Developers/API Reference]] — Full interface documentation
- [[Lead/Server Owners/Overview]] — Plugin overview and installation
- [[Lead/Server Owners/Commands]] — Command reference