Skip to content
GameCoinDocs
Dashboard

Ledger API

Read the immutable history of every change to a player's balances, page by page, with the server API.

On this page

The ledger is the history of a wallet: one entry for every grant, spend, pack delivery and refund, never edited and never deleted. Read it to show a player their history, to answer a support request, or to reconcile your own records. The examples on this page continue from the setup.

Returns a page of a player's ledger entries, newest first. Use currency to keep one currency, and limit and cursor to walk back in time.

GET/api/v1/players/{player}/ledger
  • Authenticationsecret key
  • Idempotencynot needed

Parameters

ParameterTypeDescription
playerstringA GameCoin player id, or ext:<your id> URL-encoded once.

Query

ParameterTypeRequiredRules
currencystringnoOnly the entries of this currency (2 to 24 lowercase characters). A well-formed code that has no entries gives an empty list.
limitintegernoPage size, from 1 to 100. Default 20.
cursorstringnoThe nextCursor of the previous page. Opaque: never build one.

Response

200 OK: a page of LedgerEntry objects and the cursor of the next page.

FieldTypeDescription
entriesarrayThe entries of the page, newest first.
nextCursorstring or nullPass it as cursor to get the next page. null on the last page.

To get the next page, pass the cursor back; the other parameters stay the same:

The SDKs can follow the cursors for you. iterate fetches a page only when your loop reaches it, so you can stop whenever you want; limit is the page size:

Errors

StatusCodeWhenWhat to do
400VALIDATION_FAILEDlimit is not a whole number from 1 to 100 (details.fieldErrors.limit); currency is malformed; cursor is not one this API issued (CURSOR_INVALID); the player reference is malformed (PLAYER_REF_INVALID)Fix the parameter. Never edit a cursor: pass back the one you received.
404NOT_FOUNDThe player does not existAn ext: player exists after its first write; before that it has no history.

Notes

  • Every entry carries balanceAfter, the balance right after it, so you can display a running balance without adding anything up. paidDelta and bonusDelta are negative for a spend.
  • ref.itemSku is set on a purchase of an item and ref.orderId on an entry caused by an order (pack delivery, refund). The entry types are listed in Objects.
  • Entries are never edited: an error is corrected by a new entry, not by changing an old one.
  • A parameter this API does not know is ignored, not refused. A currency that is well-formed but unknown to the game is not an error either: you get an empty page.
  • Ids sort by creation time. Paging goes back in time from the newest entry, so entries written while you page do not shift the pages behind you.