Developer Resources / Build / Concepts

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:

WhoDoes whatWhere
Your account admins (or Claude)Design the game: events, missions, achievements, levels, streaks, leaderboards and prizesThe dashboard, or Claude
Your codeCreates players, reports what they do, shows their progress and claims prizesThe GameLayer API
GameLayerWorks out what each action means: progress, rewards, level-ups, rankingsAutomatically, 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:

  1. Write: POST /events/{id}/complete when a user does something.
  2. 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#

ElementWhat it isUse it when
EventAn 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
MissionA 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
AchievementA 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"
LevelA tier players move up through by earning points, credits or achievements.You want long-term status that grows with activity
StreakA 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
LeaderboardA ranking of players or teams by score, for a period.You want competition, between players or teams
PrizeA reward players claim, usually with credits. Can have stock and claim limits.Players should be able to spend what they earn
Mystery boxLike a prize, but awards a random prize from a pool.You want surprise in the reward
RafflePlayers buy tickets with credits; winners are drawn at a set time.You have a few big prizes for many players
QuizScored questions with a pass rate. Rewards on a pass.You want to check knowledge, such as after training
SurveyQuestions without right answers. Always rewards.You want feedback, and to reward giving it
RuleMultiplies the points players earn when its conditions match.You want a promotion, such as double points this weekend
TeamA 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:

ElementIDSet up as
Eventcomplete-lessonAwards 10 points and 5 credits each time
Missionweekly-lessonsComplete 5 lessons in a week. Awards 50 credits. Repeats weekly.
Missiondaily-lessonComplete 1 lesson in a day. Repeats daily.
Streaklesson-streakCounts days in a row with daily-lesson completed
Achievementseven-day-learner1 step, from a 7-day lesson-streak
Prizecup-coffeeCosts 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:

CurrencyBehaviourUsed for
PointsBuild up over time. Never go down through player actions; an update from your backend can lower them.Progression and ranking: levels and leaderboards
CreditsA balance that goes up when earned and down when spentThe 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, premium or enterprise.
  • Tags: any number of labels, such as mobile, referral or vip.

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:00 to UTC+12:00, plus UTC+14:00. Half-hour zones such as India's UTC+05:30 aren't accepted; use the nearest whole hour.
  • No daylight saving: the offset is fixed. A player in Finland is UTC+02:00 in winter and UTC+03:00 in 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:

StepWhat happensWhere it shows in progress
1. EventThe event completes and awards points, credits and achievement stepspoints, credits
2. RulesMatching rules multiply the pointsrules, and points.earned
3. MissionsMissions that include the event progress. Completed missions award their reward.startedMissions, missions
4. StreaksStreaks update when a mission linked to them completes. A missed period resets the streak.activeStreaks, completedStreaks
5. AchievementsAchievements gain steps from events, missions and streaks. Completed achievements award their reward, and can add steps to other achievements.unlockedAchievements, achievements
6. LevelsLevels are checked. The player can move up several levels at once.levels.completed, levels.started
7. LeaderboardsPlayer and team scores updateNot 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 404 with error code 100.