Skip to content
Skip the menu

Guides

Free currencies and items

Hand out currency and items from your server, let players buy and use items, and know the limits that apply.

View as Markdown

On this page

What you will do

Not everything is sold for euros. Players also earn coins by playing, and spend them on items. This guide covers:

  • granting currency from your server (daily rewards, quests, prizes);
  • granting an item;
  • buying an item with a currency;
  • consuming an item;
  • the limits that cap each of them.

The examples use a free currency gold, the paid currency gems, a consumable item potion (20 gems) and a durable item fire-sword (300 gems, one at most). Set up in the dashboard: A game without a backend. A free currency is « Gratuite » in the dashboard; a paid one is « Payante ».

Grant currency

Only your server grants (or the dashboard, for a manual gift). A grant always credits the free bonus bucket, for a free currency and for a paid one.

POST/players/{player}/wallet/grant
LangageLanguage
curl -X POST "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/wallet/grant" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Idempotency-Key: daily-user-42-2026-10-05" \
  -H "Content-Type: application/json" \
  -d '{"currency":"gold","amount":50,"reason":"daily_reward","metadata":{"day":"3"}}'

reason and metadata come back in the ledger, so use them to say why: a quest id, a match id, a day. The idempotency key is what makes a daily reward daily: the key daily-user-42-2026-10-05 can be sent as often as you like and pays once. See Idempotency.

Give an item

An item can also be given. This adds units to the player's inventory.

POST/players/{player}/inventory/grant
LangageLanguage
curl -X POST "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/inventory/grant" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Idempotency-Key: welcome-potions-user-42" \
  -H "Content-Type: application/json" \
  -d '{"sku":"potion","quantity":3}'
Answer
{ "item": { "sku": "potion", "quantity": 3, "updatedAt": "2026-10-05T21:55:10.200Z" } }

quantity is optional and defaults to 1. The answer is the item as the player now holds it: quantity is the total, not the amount added.

Buy an item with a currency

An item with a price is bought with its own currency. The wallet is debited and the item added in one step: either both happen or neither does. In the examples, a player with 1000 gems and no potion buys two potions.

POST/players/{player}/purchases
LangageLanguage
curl -X POST "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/purchases" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Idempotency-Key: potions-user-42-order-9" \
  -H "Content-Type: application/json" \
  -d '{"sku":"potion","quantity":2}'
Answer to the server call
{
  "entry": {
    "id": "6ac419ee0b7ba2060d7ef399",
    "type": "spend",
    "currency": "gems",
    "paidDelta": 0,
    "bonusDelta": -40,
    "balanceAfter": { "paid": 0, "bonus": 960, "total": 960 },
    "reason": null,
    "metadata": {},
    "ref": { "itemSku": "potion" },
    "createdAt": "2026-10-05T21:43:10.807Z"
  },
  "balance": { "currency": "gems", "paid": 0, "bonus": 960, "total": 960 },
  "item": { "sku": "potion", "quantity": 2, "updatedAt": "2026-10-05T21:43:10.871Z" }
}

The purchase is a spend entry whose ref.itemSku names the item. It follows the same rules as every spend: free coins first, and 409 INSUFFICIENT_FUNDS if the player cannot afford it.

An item with no price (price: null) cannot be bought with a currency: give it, or sell it inside a pack.

Consume an item

A consumable item is used up. This removes units from the inventory. In the examples, the player who just bought two potions drinks one.

POST/players/{player}/inventory/consume
LangageLanguage
curl -X POST "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/inventory/consume" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY" \
  -H "Idempotency-Key: drink-user-42-1" \
  -H "Content-Type: application/json" \
  -d '{"sku":"potion"}'

The answer carries the item as it is now, even when it reaches 0. Reading the inventory lists only items the player owns (quantity above 0). Here it is the inventory of a player who owns a fire-sword and one potion:

LangageLanguage
curl "https://gamecoin.apilow.com/api/v1/players/ext%3Auser-42/inventory" \
  -H "Authorization: Bearer $GAMECOIN_SECRET_KEY"

The limits

LimitWhere it comes fromWhat you get when you hit it
Items ownedmaxOwned on the item. A durable item has 1 by default; a consumable has no limit.409 LIMIT_REACHED, with details.maxOwned and details.owned
Packs boughtmaxPerPlayer on the pack409 LIMIT_REACHED, with details.maxPerPlayer and details.bought
CurrencyYou cannot spend more than the balance409 INSUFFICIENT_FUNDS, with details.required and details.available
Items to consumeYou cannot consume more than the player owns409 INSUFFICIENT_FUNDS, with details.required and details.available
AmountsOne operation moves 1 to 1 000 000 000 000 units; a balance stays under 10¹⁵400 VALIDATION_FAILED, or 409 LIMIT_REACHED

A second purchase of a durable item shows the first limit:

Buying the fire-sword twice
{
  "error": {
    "code": "LIMIT_REACHED",
    "message": "Item ownership limit exceeded",
    "details": { "maxOwned": 1, "owned": 1 }
  }
}

A durable item cannot be consumed: 409 CONFLICT. It stays. Use consume only on consumables.

Consuming the fire-sword
{ "error": { "code": "CONFLICT", "message": "A durable item cannot be consumed" } }

Treat both as normal cases. In a shop, hide the "buy" button of an item the player already owns, and show a message instead of an error.

Who may do what

ActionServer (secret key)Browser (publishable key + token)
Grant currencyyesnever
Grant an itemyesnever
Buy an item with a currencyyesyes, if the item is « Achetable depuis le jeu »
Consume an itemyesyes
Spend currency without an itemyesyes

An item that is not buyable from the game answers 403 FORBIDDEN when the browser tries to buy it. Keep valuable items that way, and sell them from your server, which can check the rules of your game first.

Where next