Concepts
This page explains how GameLayer works. Your app reports what players do, and GameLayer works out what it means for their progress.
How GameLayer fits in#
The game is designed in one place, and your code drives it from another:
| Who | Does what | Where |
|---|---|---|
| Your account admins (or Claude) | Design the game: events, missions, achievements, levels, streaks, leaderboards and prizes | The dashboard, or Claude |
| Your code | Creates players, reports what they do, shows their progress and claims prizes | The GameLayer API |
| GameLayer | Works out what each action means: progress, rewards, level-ups, rankings | Automatically, on every call |
There are no GameLayer API calls to create missions or prizes. To create them in code, see Admin API and agents.
Your app mostly needs two kinds of call:
- Write:
POST /events/{id}/completewhen a user does something. - Read:
GET /players/{player}/…to show their progress.
Everything else, such as mission progress, achievement steps, level-ups and leaderboard scores, happens automatically.
Game elements#
| Element | What it is | Use it when |
|---|---|---|
| Event | An action a player takes in your app, reported with POST /events/{id}/complete. Every other element builds on events. | Always: every action you want to reward is an event |
| Mission | A goal made of events (or other missions, a quiz or a survey), such as "Complete 5 lessons this week". Can repeat each period. | You want a goal with a deadline or a repeating target |
| Achievement | A milestone reached in steps. Steps come from events, missions, quizzes, surveys and other achievements. Never resets. | You want a one-off badge that stays earned, such as "100 lessons" |
| Level | A tier players move up through by earning points, credits or achievements. | You want long-term status that grows with activity |
| Streak | A count of periods in a row in which the player completed a mission. Resets if they miss one. | You want to build a habit, such as a lesson every day |
| Leaderboard | A ranking of players or teams by score, for a period. | You want competition, between players or teams |
| Prize | A reward players claim, usually with credits. Can have stock and claim limits. | Players should be able to spend what they earn |
| Mystery box | Like a prize, but awards a random prize from a pool. | You want surprise in the reward |
| Raffle | Players buy tickets with credits; winners are drawn at a set time. | You have a few big prizes for many players |
| Quiz | Scored questions with a pass rate. Rewards on a pass. | You want to check knowledge, such as after training |
| Survey | Questions without right answers. Always rewards. | You want feedback, and to reward giving it |
| Rule | Multiplies the points players earn when its conditions match. | You want a promotion, such as double points this weekend |
| Team | A group of players, for team leaderboards. | Players should compete together |
A worked example#
The guides use one example: a learning app. New trial accounts come with it already set up:
| Element | ID | Set up as |
|---|---|---|
| Event | complete-lesson | Awards 10 points and 5 credits each time |
| Mission | weekly-lessons | Complete 5 lessons in a week. Awards 50 credits. Repeats weekly. |
| Mission | daily-lesson | Complete 1 lesson in a day. Repeats daily. |
| Streak | lesson-streak | Counts days in a row with daily-lesson completed |
| Achievement | seven-day-learner | 1 step, from a 7-day lesson-streak |
| Prize | cup-coffee | Costs 100 credits |
Your code only sends complete-lesson each time a user finishes a lesson. One call can award the points and credits, complete daily-lesson, add a day to lesson-streak, and on the fifth lesson of the week complete weekly-lessons. After 7 days in a row, the player earns Seven-day learner. Once they have 100 credits, they can claim cup-coffee. The Quickstart makes these calls.
Points and credits#
GameLayer has two currencies:
| Currency | Behaviour | Used for |
|---|---|---|
| Points | Build up over time. Never go down through player actions; an update from your backend can lower them. | Progression and ranking: levels and leaderboards |
| Credits | A balance that goes up when earned and down when spent | The economy: prizes, mystery boxes and raffle tickets |
Players earn both as rewards from events, missions, achievements, levels, streaks, quizzes and surveys. Each element's reward is set when it's designed. Rules multiply the points earned. Credits go down when a player claims a prize or a mystery box, or buys a raffle ticket.
To correct a balance, update the player with PATCH /players/{player}. A negative points or credits value lowers it, or mode: "set" replaces it. There's no floor, so a balance can go below zero. See Adjust points and credits.
Categories and tags#
Use them to segment players:
- Category: one group per player, such as
free,premiumorenterprise. - Tags: any number of labels, such as
mobile,referralorvip.
Both can be used in requirements, and to filter lists. Events can also carry tags when they're completed.
Teams#
A player is in at most one team. Set the team field when you create the player, or later with PATCH /players/{player}. See Update players and Leaderboards for team rankings.
Requirements#
Most elements can have a requirement: conditions a player must meet to be eligible. A player must meet all of them:
- Tags: has every listed tag
- Missions: has completed every listed mission
- Achievements: has completed every listed achievement
- Level: has reached at least this level
- Category: belongs to this category
Requirements are checked when the player interacts, such as completing an event or claiming a prize. An element the player isn't eligible for is left out of lists filtered by player, and the action is refused.
Periods#
Many elements reset on a period: daily, weekly, monthly or all-time, which never resets. Daily periods reset every day, weekly ones on Monday and monthly ones on the 1st, all at 00:00.
- Missions reset at midnight in the player's refresh offset.
- Streaks, prizes and mystery boxes reset at 00:00 UTC, whatever the player's offset.
- At a reset, progress toward an unfinished mission is lost, not carried over. A player who did 3 of 5 lessons in a weekly mission starts again from 0 on Monday. Rewards already given are kept.
Refresh offset#
Each player has a refreshOffset, such as UTC+02:00, that sets when their missions roll over. A player in Helsinki and a player in New York each get a fresh day at their own midnight. Without an offset, missions roll over at 00:00 UTC.
For example, a player on UTC+02:00 gets:
- a new day at 00:00 local time (22:00 UTC)
- weekly missions reset on Monday at 00:00 local time (Sunday 22:00 UTC)
- monthly missions reset on the 1st at 00:00 local time
Things to know:
- Whole hours only: from
UTC-12:00toUTC+12:00, plusUTC+14:00. Half-hour zones such as India'sUTC+05:30aren't accepted; use the nearest whole hour. - No daylight saving: the offset is fixed. A player in Finland is
UTC+02:00in winter andUTC+03:00in summer, so update their offset when the clocks change if the exact reset time matters.
The progression cascade#
One call to POST /events/{id}/complete can set off a chain of updates. They happen in this order, and the response's progress object reports each one:
| Step | What happens | Where it shows in progress |
|---|---|---|
| 1. Event | The event completes and awards points, credits and achievement steps | points, credits |
| 2. Rules | Matching rules multiply the points | rules, and points.earned |
| 3. Missions | Missions that include the event progress. Completed missions award their reward. | startedMissions, missions |
| 4. Streaks | Streaks update when a mission linked to them completes. A missed period resets the streak. | activeStreaks, completedStreaks |
| 5. Achievements | Achievements gain steps from events, missions and streaks. Completed achievements award their reward, and can add steps to other achievements. | unlockedAchievements, achievements |
| 6. Levels | Levels are checked. The player can move up several levels at once. | levels.completed, levels.started |
| 7. Leaderboards | Player and team scores update | Not in progress: read the leaderboard |
See the full response in step 2 of the Quickstart.
Location-aware elements#
Missions, prizes, mystery boxes and raffles can be tied to a place. Each has two zones around it:
- Actionable zone (inner): the player must be here to complete a mission objective or claim.
- Viewable zone (outer): the player must be here to see the element in lists.
Send the player's lat and lon when listing, completing events and claiming. Without coordinates, location-aware elements are left out of lists and event progress, and claims answer with code 7. Elements without a location work the same with or without coordinates. See Location-aware elements in the Integration guide.
Languages#
Elements can have translated names and descriptions. Pass language with an ISO 639-1 code, such as fr, on player-facing GET requests to get them in that language.
An account offers languages chosen in the dashboard from these 18 codes: en es fr de it pt nl sv fi da no pl ru tr ar zh ja ko.
- Most elements: if there's no translation in the requested language, you get the default text, with status
200. - Leaderboards: a missing translation answers
404with error code100.