WebInventory developer docs
Two ways to integrate with WebInventory:
- Java API for plugins on the same server: read players' web data, add your own statistics and leaderboards, react to events, plug in item/economy/storage providers and web routes.
- REST API for bots, websites and other servers (see REST API below and
/docs/openapi.jsonon any WebInventory server).
Java API
Setup
The API classes are in the plugin jar. Compile against the jar you download (it is never needed at runtime by your plugin; WebInventory provides the classes). With Gradle:
dependencies {
compileOnly(files("libs/WebInventory-1.6.7.jar"))
}plugin.yml:
softdepend: [WebInventory] # or depend: if your plugin cannot work without itGet the API from Bukkit's services manager (after WebInventory enabled, e.g. in your onEnable when it is a dependency):
WebInventoryApi api = Bukkit.getServicesManager().load(WebInventoryApi.class);
if (api == null) {
getLogger().info("WebInventory not installed, integration disabled");
return;
}WebInventoryApi.API_VERSION is 2; methods marked "since API 2" need WebInventory 1.6.2 or newer. All methods are thread-safe.
Read what the web shows
api.getPlayerData(player.getUniqueId()).ifPresent(data -> {
// a copy without the sections the player or the server hides
data.getInventory(); // List<ItemData>, null slots are empty
data.getEnderChest();
data.getStatistics(); // play_one_minute, mob_kills, deaths, ...
data.getLevel();
data.isOnline();
});
boolean shown = api.isVisible(uuid); // on the web with at least one section
Optional<String> link = api.getProfileUrl("Steve"); // https://your-site/?player=Steve| Method | Since | Returns |
|---|---|---|
getPlayerData(UUID) / getPlayerData(String name) | API 2 | Optional<InventoryData>, a public copy |
isVisible(UUID) | API 2 | true if any section is shown |
getProfileUrl(String name) | API 2 | link to the player's page (uses web.base-url) |
Add your own statistic and leaderboard
A statistic you register appears in every player's Statistics tab and, by default, as a leaderboard: on the Top page, in /winv top <id>, in the Bedrock menu and in PlaceholderAPI (%webinv_top_<id>_1_name%, %webinv_top_<id>_1_value%, %webinv_rank_<id>%).
api.registerStatistic(CustomStatistic.builder(this, "island_level")
.displayName("Island level") // shown on the web and in chat
.unit(StatUnit.COUNT) // COUNT, TICKS (duration) or CENTIMETERS (distance)
.value(player -> islands.getLevel(player.getUniqueId()))
.leaderboard(true) // default
.build());
// full id: <yourplugin>_<id>, e.g. skyblock_island_level- The value function runs on the player's own thread (main thread on Paper, the player's region on Folia) whenever WebInventory takes a snapshot of that player (join, inventory changes, autosave). Keep it fast: read from your own cache, never block on a database.
- The last value is saved with the player's data, so offline players stay on the leaderboard.
- Only players who share their statistics are shown, like the built-in statistics.
- Registering the same id again replaces it. Statistics are removed automatically when your plugin disables;
api.unregisterStatistics(this)removes them earlier.
Leaderboards
List<String> ids = api.getLeaderboardIds(); // playtime, mob_kills, ..., skyblock_island_level
for (LeaderboardEntry e : api.getLeaderboard("playtime")) {
e.rank(); e.name(); e.uuid(); e.value(); e.formatted(); e.online();
}Leaderboards are cached and rebuilt every leaderboards.refresh-seconds. value is raw (ticks, centimetres or a count); formatted is what the web page shows ("12h 5m", "3.4 km", "1,234").
Events
All events are in com.webinventory.events and are called on the server (main/global) thread.
| Event | When |
|---|---|
PlayerDataUpdatedEvent | a player's snapshot was refreshed (getData() is the full data, including hidden sections: respect the player's choice) |
WebInventoryStatusChangeEvent | a player showed or hid their profile or a section (getOldFeatures(), getNewFeatures(), getChangeType()) |
StoreTransactionEvent | a web store purchase or sale (in-game currency) |
PaymentCompletedEvent | a real-money payment was verified and delivered |
RankPurchaseEvent | a rank was bought |
StoreItemChangeEvent, StoreCategoryChangeEvent | an admin changed the store |
TicketCreatedEvent, TicketReplyEvent, TicketStatusChangeEvent | support tickets |
AdminLoginEvent, LinkCodeVerifiedEvent | web admin logins and account links |
@EventHandler
public void onShown(WebInventoryStatusChangeEvent event) {
if (event.getNewFeatures().isInventory()) {
// the player's inventory is now public
}
}Extension points
| Method | Use |
|---|---|
registerItemProvider(ItemProvider) | custom items in the web store (like the built-in ItemsAdder, MMOItems, Oraxen, Nexo providers) |
registerEconomyProvider(EconomyProvider) | a currency for the web store besides Vault and PlayerPoints |
registerStorageProvider(StorageProvider) | another database for player data (database.type in config.yml) |
registerRouteRegistrar(RouteRegistrar) | your own HTTP routes on WebInventory's web server (Javalin) |
registerPermissionHook(...) | a permission plugin for prefixes, groups and rank purchases |
Configuration for integrators
Server owners can switch parts of the web page off in config.yml under web.ui (favorites, export JSON, refresh button, 3D skin, status bars, potion effects, level panel, last updated, online badge, online players list, name suggestions, item search, theme switch, Discord avatar, Bedrock badge). /api/settings returns them as ui, plus the registered statistics as statistics (id, name, unit), so a custom front end can follow the same choices.
REST API
Every WebInventory server serves its API under /api/v1 and its OpenAPI 3 description at /docs/openapi.json (open it in Swagger UI, Postman or Insomnia).
- Public (what the web page itself uses, per-IP rate limits):
GET /api/v1/settings,/players(?online=true,?q=,?limit=&offset=),/player/{name},/player/{name}/inventory,/player/{name}/enderchest,/search?q=,/leaderboards. Player data sends anETag; revalidate withIf-None-Matchfor a304. - Developer API keys (Premium):
/winv admin apikey create <name> read|live|adminin the console. SendX-API-Key: winv_.... Scopes:read(own rate limit,api.rate-limitper minute),live(WebSocket/ws/inventory/*, every player's updates; in a browser URL only a key whose only scope islive),admin(admin endpoints, still limited to the admin IP whitelist; audited under the key's name). - Errors are
{"error": "message", "code": "not_found"}; codes:bad_request,unauthorized,invalid_api_key,premium_required,forbidden,not_found,conflict,length_required,too_large,rate_limited(withRetry-After),unavailable,internal_error. - Live updates:
ws://<server>:8081/ws/inventory/<name>(Premium) sends{"type":"inventory_update","player":"Steve","data":{...}}and{"type":"player_disabled",...}.
REST API reference
The full OpenAPI 3 description of the plugin's API, the same file every server serves at /docs/openapi.json. Import it into Swagger UI, Postman or Insomnia. Every path below is also served without the /api/v1 prefix.
| Method | Path | Summary | Auth |
|---|---|---|---|
| GET | /api/v1/health | Server is up; plugin version | None (API key optional) |
| GET | /api/v1/settings | Enabled modules, language, theme, premium flag | None (API key optional) |
| GET | /api/v1/players | Players visible on the web | None (API key optional) |
| GET | /api/v1/player/{username} | One player (Discord link, skin) | None (API key optional) |
| GET | /api/v1/player/{username}/inventory | Full snapshot: inventory, armor, off-hand, ender chest, stats, advancements, effects | None (API key optional) |
| GET | /api/v1/player/{username}/enderchest | Ender chest only | None (API key optional) |
| GET | /api/v1/search | Find an item across visible inventories | None (API key optional) |
| GET | /api/v1/leaderboards | Every leaderboard (cached; refreshSeconds) | None (API key optional) |
| GET | /api/v1/texture/{material} | Item icon (PNG) | None (API key optional) |
| GET | /api/v1/admin/items | Store items (admin) | API key, admin scope |
| GET | /api/v1/admin/transactions | Store transactions (admin) | API key, admin scope |
| GET | /api/v1/admin/stats | Store statistics (admin) | API key, admin scope |
The Developer API keys and live updates need a Premium license or the free trial.
See plans