Stylish Shop exposes a small public API for macros and other modules. Use it to open specific shops from a hotbar macro, register a custom system adapter, or react to transaction results. This chapter is the reference, with copy-paste examples for the patterns that come up most often.

Who Uses It

Role When
Macro author (GM) Hotkey macros that open a specific shop, opening day setup, bulk inventory cleanup.
Module developer Registering a new system adapter, listening for transactions, hooking shop updates.
GM bulk work Quick console operations on currency or pricing.

Most calls are safe for GMs. A few (processSell, Transaction.commit) include permission checks and refuse non-GM callers without the right OWNER permission.

Accessing the API

All public functions sit on game.modules.get("stylish-shop").api.

const api = game.modules.get("stylish-shop").api;
api.openShopById("MyShopActorId");

The same classes used internally (SystemAdapter, ItemStatAdapter, CurrencyAdapter) are also exposed on api, so you can extend them directly when writing a new adapter.

Console and macros both work the same way. await is available inside macros and top-level in the console.

Opening a Shop

Three functions cover slightly different needs.

Function Signature Behavior
openShopById(shopId, options?) api.openShopById("abc123", { buyerActor }) Opens the shop by actor ID. Enters as a single character. No picker.
openShopByRef(shopRef, options?) api.openShopByRef("token:scene1:tok2") Accepts both actor refs (actor:{id}) and token refs (token:{sceneId}:{tokenId}).
openShopWithBuyerSelection(shopId) api.openShopWithBuyerSelection("abc123") Shows a character picker for players with multiple owned characters. Single-character players and GMs follow the 1.3.2 standard flow.

Permission Rules

Example — Hotbar Macro That Opens a Shop

const api = game.modules.get("stylish-shop").api;
const shopActor = game.actors.getName("Blackmarket Vendor");
if (!shopActor) {
  ui.notifications.warn("Shop actor not found.");
  return;
}
api.openShopWithBuyerSelection(shopActor.id);

Example — Enter With a Specific Character

const api = game.modules.get("stylish-shop").api;
const shop = game.actors.getName("Royal Armory");
const buyer = game.actors.getName("Queen Mira");
api.openShopById(shop.id, { buyerActor: buyer });