Skip to main content

Loot Airdrops Module

The Loot Airdrops module provides functionality for interacting with the Gamanza Engage Loot Airdrops system. It allows developers to list active airdrops, history, pending claims, prize pools, player wins, and winners, as well as opt players into airdrops and claim rewards.

Accessing the Module​

The Loot Airdrops module is accessible through the Gamanza Engage Web Client SDK:

const sdk = GamanzaEngageWebClientSDK.getInstance();
const lootAirdrops = sdk.LootAirdrops;

Methods​

getPlayerActiveAirdrops​

Returns the active/scheduled airdrops visible to the authenticated player, including isPlayerEligible and localized error messages when the player is not eligible.

Signature:

getPlayerActiveAirdrops(): Promise<AirdropType[]>

Returns​

TypeDescription
Promise<AirdropType[]>A promise that resolves to an array of visible airdrops

Example​

const activeAirdrops = await sdk.LootAirdrops.getPlayerActiveAirdrops();
  • EVENTS.LOOT_AIRDROPS.ON_STATE_UPDATE — Airdrop lifecycle status changed (scheduled → active → ended / cancelled)
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED — Player newly assigned; SDK runs a single-flight fetch-and-overwrite refresh. Widgets should await refreshPlayerActiveAirdrops() and re-render from that result.

invalidatePlayerActiveAirdropsCache​

Clears the cached active airdrops list (LAD.v1.active.{playerId}) for the authenticated player. Use this when eligibility may have changed mid-session (for example after a rank-up) and the consumer will immediately call getPlayerActiveAirdrops again.

The cache delete is asynchronous. Always await this method before refetching, or the next getPlayerActiveAirdrops call can still resolve from the stale cache.

EVENTS.RANKS.ON_RANK_UP for the signed-in player also triggers this invalidation inside the SDK.

On EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED, prefer refreshPlayerActiveAirdrops instead of calling this method yourself. The SDK already refreshes on that event; a consumer-side invalidate is unnecessary and can race a concurrent plain get.

Signature:

invalidatePlayerActiveAirdropsCache(): Promise<void>

Returns​

TypeDescription
Promise<void>Resolves when the active airdrops cache entry has been cleared

Example​

await sdk.LootAirdrops.invalidatePlayerActiveAirdropsCache();
const activeAirdrops = await sdk.LootAirdrops.getPlayerActiveAirdrops();
  • EVENTS.RANKS.ON_RANK_UP — SDK clears the active airdrops cache for the authenticated player

refreshPlayerActiveAirdrops​

Fetches GET /widget/airdrops and overwrites the active airdrops cache on success. Does not delete the cache first, so a non-OK GET keeps the previous list as a stale fallback. Concurrent callers share one in-flight promise (single-flight), so the SDK's internal ON_PLAYER_ASSIGNED handler and a widget callback that awaits this method only perform one GET.

Use this on EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED instead of calling invalidatePlayerActiveAirdropsCache() + getPlayerActiveAirdrops() yourself.

Signature:

refreshPlayerActiveAirdrops(): Promise<AirdropType[]>

Returns​

TypeDescription
Promise<AirdropType[]>Fresh active airdrops, or the stale cached list / empty array on failure

Example​

sdk.Events.subscribe(EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED, async () => {
const activeAirdrops = await sdk.LootAirdrops.refreshPlayerActiveAirdrops();
updateAirdropsUI(activeAirdrops);
});
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED — SDK awaits this same single-flight refresh for the authenticated player

getPlayerAirdropsHistory​

Returns the ended/cancelled airdrops the authenticated player participated in, most recently finished first, with the airdrop metadata required for history listings.

Signature:

getPlayerAirdropsHistory(): Promise<AirdropHistoryType[]>

Returns​

TypeDescription
Promise<AirdropHistoryType[]>A promise that resolves to an array of history airdrop entries

Example​

const history = await sdk.LootAirdrops.getPlayerAirdropsHistory();
  • EVENTS.LOOT_AIRDROPS.ON_STATE_UPDATE — Airdrop ended or cancelled; history list should be refreshed

getPlayerPendingClaims​

Returns every prize the authenticated player still has to claim (unclaimed and still claimable) across all airdrops, as a flat unpaginated list. Each item includes its airdropId and isAwaitingBetSettlement.

Signature:

getPlayerPendingClaims(): Promise<AirdropPendingClaim[]>

Returns​

TypeDescription
Promise<AirdropPendingClaim[]>A promise that resolves to an array of pending claims

Example​

const claims = await sdk.LootAirdrops.getPlayerPendingClaims();

for (const claim of claims) {
console.log(claim.airdropId, claim.fireEventId, claim.expirationDate);
}
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE — Player won a prize (new pending claim may appear)
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Claim status changed (claimed / pending_settlement / expired / cancelled)

getAirdropPrizePool​

Returns the prizes configured in the airdrop's loot with their rewards, configured quantity, delivered count, and remaining units (Rewards tab). state.delivered is every unit that left the pool (quantity - remaining), including claimed, expired, cancelled, unclaimed, and pending-settlement prizes. state.percentage is the rounded delivered percentage, or 0 when quantity is 0.

Signature:

getAirdropPrizePool(airdropId: string): Promise<AirdropPrizePoolItem[]>

Parameters​

NameTypeDescription
airdropIdstringValid ObjectId of the airdrop

Returns​

TypeDescription
Promise<AirdropPrizePoolItem[]>A promise that resolves to an array of prize pool items

Example​

const prizes = await sdk.LootAirdrops.getAirdropPrizePool('airdrop-id-123');

prizes.forEach((prize) => {
console.log(
prize.prizeId,
prize.state.delivered,
prize.remaining,
prize.state.percentage,
);
});
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE — Prize remaining units may change when a win is persisted
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Prize pool state may change when a claim is settled or cancelled

getPlayerAirdropWins​

Returns the prizes the authenticated player has won for a specific airdrop, most recently won first, each with claim lifecycle status and isAwaitingBetSettlement so the UI can enable claim, show a waiting-for-settlement state, or show the final state.

Signature:

getPlayerAirdropWins(airdropId: string): Promise<AirdropPlayerWin[]>

Parameters​

NameTypeDescription
airdropIdstringValid ObjectId of the airdrop

Returns​

TypeDescription
Promise<AirdropPlayerWin[]>A promise that resolves to an array of player wins

Example​

const wins = await sdk.LootAirdrops.getPlayerAirdropWins('airdrop-id-123');

wins.forEach((win) => {
if (win.status === 'unclaimed') {
console.log('Claimable win:', win.fireEventId);
}
});
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE — Player won a prize (new win row)
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Win claim status changed

getPlayersAirdropWinners​

Returns players that have won prizes in an airdrop, one row per win, most recently won first (position 1 is the most recent), excluding cancelled wins. Offset-paginated; when omitted, the API defaults page to 1 and limit to 25 (max 100).

Signature:

getPlayersAirdropWinners(
airdropId: string,
request?: ListAirdropWinnersRequest
): Promise<ListAirdropWinnersResponse | null>

Parameters​

NameTypeDescription
airdropIdstringValid ObjectId of the airdrop
requestListAirdropWinnersRequestOptional. page (number, 1-based), limit (number, 1..100)

Returns​

TypeDescription
Promise<ListAirdropWinnersResponse | null>Paginated winners response, or null on failure with no stale cache

Example​

const winners = await sdk.LootAirdrops.getPlayersAirdropWinners('airdrop-id-123', {
page: 1,
limit: 25,
});

if (winners) {
console.log(winners.totalDocs, winners.hasNextPage);
winners.docs.forEach((row) => {
console.log(row.position, row.userName, row.animationTier);
});
}
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE — New winner row when a prize is won
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Winner list may change when a win is cancelled

playerOptInAirdrop​

Opts in the currently authenticated player to a specific airdrop. Use this only when the airdrop has optIn: true. If optIn is false, players participate automatically and this call is not required.

  • Free airdrops (BuyInOptions.FREE)
    • Behavior: Player is registered for the airdrop upon successful opt-in
    • Cost: None
    • Response: { ok: true, data: null }
  • Token buy-in airdrops (BuyInOptions.TOKENS)
    • Behavior: Validates player's virtual currency balance and deducts the entry fee on success
    • Requirement: Player must have sufficient coins/tokens
    • Errors: Returns faultCode = 402 (Payment Required) when balance is insufficient

On success, the SDK clears the active airdrops cache so subsequent reads reflect the updated state.

For token buy-in airdrops, wallet balance is updated asynchronously via EVENTS.VIRTUAL_CURRENCY.ON_WALLET_UPDATE. Do not assume getPlayer().walletData.balance already reflects the deduction right after a successful opt-in.

Signature:

playerOptInAirdrop(airdropId: string): Promise<SimpleResponse<null>>

Parameters​

NameTypeDescription
airdropIdstringThe unique identifier of the airdrop (from getPlayerActiveAirdrops)

Returns​

TypeDescription
Promise<SimpleResponse<null>>Resolves with { ok: true, data: null } on success or { ok: false, data: null, error } on failure

Error handling​

  • Insufficient funds (token buy-in): error.details.faultCode === 402
  • Other possible errors: airdrop not found, already started/ended, already opted in, maximum capacity reached
const res = await sdk.LootAirdrops.playerOptInAirdrop(airdropId);
if (!res.ok) {
switch (res.error?.details?.faultCode) {
case 402:
// Insufficient balance for airdrop entry
break;
default:
// Handle other errors
break;
}
}

Examples​

Basic (free airdrop):

const response = await sdk.LootAirdrops.playerOptInAirdrop("airdrop-id-123");
if (response.ok) {
console.log("Successfully opted into airdrop");
}

With pre-check for token buy-in:

const airdrops = await sdk.LootAirdrops.getPlayerActiveAirdrops();
const airdrop = airdrops.find(x => x._id === "airdrop-456");

if (airdrop?.buyOptions?.tokens) {
const player = await sdk.Player.getPlayer();
const balance = player?.walletData?.balance ?? 0;
if (balance < airdrop.buyOptions.tokens) {
// Prompt user to purchase more coins
}
}

const res2 = await sdk.LootAirdrops.playerOptInAirdrop("airdrop-456");
if (!res2.ok && res2.error?.details?.faultCode === 402) {
// Show insufficient funds UI
}

// After a successful token buy-in, listen for wallet updates:
// sdk.Events.subscribe(EVENTS.VIRTUAL_CURRENCY.ON_WALLET_UPDATE, (data) => { ... })
  • EVENTS.VIRTUAL_CURRENCY.ON_WALLET_UPDATE — Wallet balance after a token buy-in deduction
  • EVENTS.LOOT_AIRDROPS.ON_STATE_UPDATE — Airdrop lifecycle status changed
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED — Player newly assigned (also emitted after successful opt-in)
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE — Player won a prize
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Prize claim status changed

playerClaimAirdropReward​

Claims a still-unclaimed reward for the authenticated player. On success, invalidates pending claims, player wins, prize pool, and winners caches related to the airdrop.

Signature:

playerClaimAirdropReward(airdropId: string, fireEventId: string): Promise<SimpleResponse<null>>

Parameters​

NameTypeDescription
airdropIdstringValid ObjectId of the airdrop the reward belongs to
fireEventIdstringIdentifier of the win/fire event whose reward is being claimed

Returns​

TypeDescription
Promise<SimpleResponse<null>>{ ok: true, data: null } on HTTP 204; otherwise { ok: false, data: null, error }

Example​

const claims = await sdk.LootAirdrops.getPlayerPendingClaims();
const claim = claims[0];

if (claim) {
const result = await sdk.LootAirdrops.playerClaimAirdropReward(
claim.airdropId,
claim.fireEventId,
);

if (result.ok) {
console.log('Reward claimed');
}
}
  • EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE — Claim status update after the player claims (or settlement / expiry / cancellation)

AirdropType​

Visible (active/scheduled) airdrop for the player.

interface AirdropType {
_id: string;
externalDetails: AirdropExternalDetailsEntity[];
tags?: AirdropTag[];
smallImage?: string;
largeImage?: string;
industries?: AirdropIndustryEnum[];
gameCategories?: string[];
gameProviders?: string[];
games?: string[];
sports?: string[];
leagues?: string[];
tournaments?: string[];
teams?: string[];
markets?: string[];
optIn: boolean;
isPlayerOptIn: boolean;
buyIn?: BuyInOptions[];
buyOptions?: Record<string, number>;
minBetAmount?: Record<string, number>;
maxCapPerUser?: number;
timePeriod?: AirdropTimePeriod;
operatorTimeZone?: string;
dropLogic?: string;
timeBasedConfig?: AirdropTimeBasedConfig;
prizes?: AirdropPrize[];
claimTimerSeconds?: number;
brands?: AirdropBrand[];
eligibility?: AirdropEligibility;
visibility?: AirdropVisibility;
status: AirdropStatusEnum;
isPlayerEligible: boolean;
}

AirdropExternalDetailsEntity​

type AirdropExternalDetailsEntity = TranslationType & {
eligibilityDisplayName?: string;
};

AirdropHistoryType​

Finished airdrop for history listings (same metadata as AirdropType, without player-context flags).

type AirdropHistoryType = Omit<AirdropType, 'isPlayerEligible' | 'isPlayerOptIn'>;

AirdropPlayerWin​

interface AirdropPlayerWin {
fireEventId: string;
prizeId: string;
status: AirdropClaimStatusEnum;
wonAt: string;
expirationDate?: string;
claimTimerSeconds?: number;
rewards: AirdropWinReward[];
animationTier?: string;
prizeNumber?: number;
industry: AirdropIndustryEnum;
isAwaitingBetSettlement: boolean;
}

AirdropPendingClaim​

interface AirdropPendingClaim extends AirdropPlayerWin {
airdropId: string;
}

LootAirdropPlayerWonPrizeEventData / LootAirdropPlayerPrizeStatusUpdateEventData​

RTM payloads for prize win and claim-status updates. See docs/rtm-events.module.md for subscription examples.

interface LootAirdropPlayerWonPrizeEventData extends BaseEventData {
airdropId: string;
externalDetails: AirdropExternalDetailsEntity[];
playerId: string;
prizeId: string;
fireEventId: string;
prizeNumber?: number;
animationTier?: string;
rewards: Reward[];
status: AirdropClaimStatusEnum;
industry: AirdropIndustryEnum;
isAwaitingBetSettlement: boolean;
timestamp: string;
}

interface LootAirdropPlayerPrizeStatusUpdateEventData extends BaseEventData {
airdropId: string;
externalDetails: AirdropExternalDetailsEntity[];
playerId: string;
prizeId: string;
fireEventId: string;
claimStatus: AirdropClaimStatusEnum;
animationTier?: string;
rewards: Reward[];
industry: AirdropIndustryEnum;
timestamp: string;
}

AirdropPrizePoolItem​

interface AirdropPrizePoolItem {
prizeId: string;
quantity: number;
animationTier?: string;
rewards: Reward[];
remaining: number;
state: AirdropPrizePoolState;
prizeNumber?: number;
}

interface AirdropPrizePoolState {
percentage: number;
delivered: number;
}

AirdropWinner​

interface AirdropWinner {
position: number;
wonAt: string;
playerId: string;
userName?: string;
level?: number;
rank?: string;
rankImageUrl?: string;
animationTier?: string;
earnedRewards: AirdropWinReward[];
}

ListAirdropWinnersRequest / ListAirdropWinnersResponse​

interface ListAirdropWinnersRequest {
page?: number;
limit?: number;
}

interface ListAirdropWinnersResponse {
docs: AirdropWinner[];
totalDocs: number;
limit: number;
page: number;
totalPages: number;
hasPrevPage: boolean;
hasNextPage: boolean;
}

AirdropOptInRequest / AirdropClaimRewardRequest​

interface AirdropOptInRequest {
airdropId: string;
}

interface AirdropClaimRewardRequest {
airdropId: string;
fireEventId: string;
}

AirdropClaimStatusEnum​

enum AirdropClaimStatusEnum {
UNCLAIMED = 'unclaimed',
CLAIMED = 'claimed',
EXPIRED = 'expired',
PENDING_SETTLEMENT = 'pending_settlement',
CANCELLED = 'cancelled',
}

AirdropStatusEnum​

enum AirdropStatusEnum {
IN_DESIGN = 'in_design',
SCHEDULED = 'scheduled',
ACTIVE = 'active',
ENDED = 'ended',
CANCELLED = 'cancelled',
}

AirdropIndustryEnum​

enum AirdropIndustryEnum {
CASINO = 'casino',
SPORT = 'sport',
}

SimpleResponse<T>​

interface SimpleResponse<T> {
ok: boolean;
error?: ErrorResponse;
data: T | null;
}

Cache Keys​

PrefixUsed by
LAD.v1.activegetPlayerActiveAirdrops
LAD.v1.historygetPlayerAirdropsHistory
LAD.v1.pending-claimsgetPlayerPendingClaims
LAD.v1.prize-poolgetAirdropPrizePool
LAD.v1.player-winsgetPlayerAirdropWins
LAD.v1.winnersgetPlayersAirdropWinners

playerOptInAirdrop clears the active airdrops cache. playerClaimAirdropReward clears pending claims, player wins, prize pool, and winners caches for the affected airdrop. See invalidatePlayerActiveAirdropsCache above for the await-before-refetch contract on rank-up; EVENTS.RANKS.ON_RANK_UP also clears the active airdrops cache for the authenticated player. On EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED, use refreshPlayerActiveAirdrops (single-flight fetch-and-overwrite) so CRM/segmentation assignments appear without a reload and a failed GET keeps the previous cached list. Real-time events also invalidate the related LAD.v1.* caches automatically; see each method's Related Events section and docs/rtm-events.module.md for the full event catalog.

Token buy-in balance changes arrive via EVENTS.VIRTUAL_CURRENCY.ON_WALLET_UPDATE (not via active-airdrops cache invalidation).