Skip to content
# developer docs

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.json on 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:

kotlin Β· build.gradle.kts
dependencies {
    compileOnly(files("libs/WebInventory-1.6.7.jar"))
}

plugin.yml:

yaml Β· plugin.yml
softdepend: [WebInventory]   # or depend: if your plugin cannot work without it

Get the API from Bukkit's services manager (after WebInventory enabled, e.g. in your onEnable when it is a dependency):

java
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

java
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
MethodSinceReturns
getPlayerData(UUID) / getPlayerData(String name)API 2Optional<InventoryData>, a public copy
isVisible(UUID)API 2true if any section is shown
getProfileUrl(String name)API 2link 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>%).

java
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

java
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.

EventWhen
PlayerDataUpdatedEventa player's snapshot was refreshed (getData() is the full data, including hidden sections: respect the player's choice)
WebInventoryStatusChangeEventa player showed or hid their profile or a section (getOldFeatures(), getNewFeatures(), getChangeType())
StoreTransactionEventa web store purchase or sale (in-game currency)
PaymentCompletedEventa real-money payment was verified and delivered
RankPurchaseEventa rank was bought
StoreItemChangeEvent, StoreCategoryChangeEventan admin changed the store
TicketCreatedEvent, TicketReplyEvent, TicketStatusChangeEventsupport tickets
AdminLoginEvent, LinkCodeVerifiedEventweb admin logins and account links
java
@EventHandler
public void onShown(WebInventoryStatusChangeEvent event) {
    if (event.getNewFeatures().isInventory()) {
        // the player's inventory is now public
    }
}

Extension points

MethodUse
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 an ETag; revalidate with If-None-Match for a 304.
  • Developer API keys (Premium): /winv admin apikey create <name> read|live|admin in the console. Send X-API-Key: winv_.... Scopes: read (own rate limit, api.rate-limit per minute), live (WebSocket /ws/inventory/*, every player's updates; in a browser URL only a key whose only scope is live), 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 (with Retry-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.

MethodPathSummaryAuth
GET/api/v1/healthServer is up; plugin versionNone (API key optional)
GET/api/v1/settingsEnabled modules, language, theme, premium flagNone (API key optional)
GET/api/v1/playersPlayers visible on the webNone (API key optional)
GET/api/v1/player/{username}One player (Discord link, skin)None (API key optional)
GET/api/v1/player/{username}/inventoryFull snapshot: inventory, armor, off-hand, ender chest, stats, advancements, effectsNone (API key optional)
GET/api/v1/player/{username}/enderchestEnder chest onlyNone (API key optional)
GET/api/v1/searchFind an item across visible inventoriesNone (API key optional)
GET/api/v1/leaderboardsEvery leaderboard (cached; refreshSeconds)None (API key optional)
GET/api/v1/texture/{material}Item icon (PNG)None (API key optional)
GET/api/v1/admin/itemsStore items (admin)API key, admin scope
GET/api/v1/admin/transactionsStore transactions (admin)API key, admin scope
GET/api/v1/admin/statsStore statistics (admin)API key, admin scope

The Developer API keys and live updates need a Premium license or the free trial.

See plans