Skip to content

Store API Integration

serdarakay edited this page Jun 20, 2025 · 1 revision

πŸ”Ή Using GameDistribution Store API in GameMaker

You can integrate the GameDistribution Store API into your GameMaker: HTML5 projects using the built-in JavaScript extension support. This enables you to fetch virtual store items, manage user inventory, and handle purchases through GameDistribution's store platform.


βœ… 1. Setup Instructions

To get started:

  1. Export your project as HTML5.
  2. Open the generated index.html.
  3. Add the following inside the <head> tag:
<script type="text/javascript">
  window["GD_OPTIONS"] = {
    gameId: "your-game-id",
    onEvent: function(event) {
      console.log("GD Event:", event);
    }
  };
</script>
<script src="https://html5.api.gamedistribution.com/main.js"></script>

βœ… Make sure to replace your-game-id with your actual GameDistribution game ID.


✍️ 2. Using the Store API from GameMaker

Use the external_call function to call the GameDistribution store API directly from GameMaker.

Example: Fetch Store Items

var script = "gdsdk.executeStoreAction({ action: 'api.items' }).then((items) => { console.log('Store Items:', items); });";
external_call("eval", script);

Example: Buy a Product

var script = "gdsdk.executeStoreAction({ action: 'api.buyProduct', payload: { sku: 'ss-enhance-shield-5', quantity: 1 } });";
external_call("eval", script);

πŸ“ˆ 3. UI Integration

You can also trigger store UI interactions:

Open Store UI

external_call("eval", "gdsdk.executeStoreAction({ action: 'ui.open' });");

Close Store UI

external_call("eval", "gdsdk.executeStoreAction({ action: 'ui.close' });");

πŸ“œ Related Docs

πŸ”— GameDistribution HTML5 SDK - Store API Usage

If you would like an example GameMaker HTML5 project with full Store API integration, please contact the GameDistribution team.