This document details the methods available through the Campaign Codex API.
Accessing the API
To use the API commands, you must first get the API object. This can be done in a macro or via the developer console.
const campaignCodexAPI = game.modules.get('campaign-codex')?.api;
API Methods
convertJournalToCCSheet (DEPRECATED in v6+)
exportToObsidian
Exports your Campaign Codex content into a .zip archive containing Markdown (.md) files, suitable for use in Obsidian or other Markdown editors.
Syntax
campaignCodexAPI.exportToObsidian();
Parameters
This method takes no parameters.
openTOCSheet (DEPRECATED in v6+)
openHub
Opens the main Hub sheet for the Campaign Codex.
Syntax
campaignCodexAPI.api.openHub();
showContainer
Opens an Item Container popup from a Campaign Codex journal.
campaignCodexAPI.showContainer(journalUuid, widgetId, containerId, hideGM);
Parameters
journalUuid: String
The UUID of the journal containing the item container widget.widgetId: String
The ID of the Item Containers widget on the journal.containerId: String
The ID of the container to open.- hideGM: Boolean; optional defaults to false
- If using as a region behaviour, a token moving into the region can trigger for the GM user, set this to true to stop the container opening on the GM screen
Example
campaignCodexAPI.showContainer(
"JournalEntry.nXruOfDMPwMNPxQX",
"Zu9G1a5RZILD5qLX",
"IMOAzVvtI2IWaQ4n"
);