Skip to documentation
AdQuestDocs

Reward methods

Client methods for balances, lotteries, entries and claims.

On this page

getTokenBalance

Reads the participant’s token balance. Needs a participant token.

Signature
getTokenBalance(): Promise<TokenBalance>

Returns: A Promise of { tokens, platformUserId, externalUserId, available?, pending?, lifetime? }.

getTokenBalanceHistory

Reads the participant’s token transactions, newest first. Needs a participant token.

Signature
getTokenBalanceHistory(options?: { page?: number; perPage?: number }): Promise<TokenLedgerHistoryResult>
ParameterTypeDescription
options.pagenumberPage number.
options.perPagenumberItems per page.

Returns: A Promise of { items, currentPage, lastPage, total, perPage }.

getLotteries

Lists lotteries visible to the participant. Needs a participant token.

Signature
getLotteries(options?: GetLotteriesOptions): Promise<LotteryListResult>
ParameterTypeDescription
options.filterLotteryFilteractive (default), upcoming, completed or all.
options.pagenumberPage number.
options.perPagenumberItems per page.

Returns: A Promise of { lotteries, pagination }.

getLottery

Loads one lottery with its prizes and the participant’s own entry count. Needs a participant token.

Signature
getLottery(lotteryId: number): Promise<LotteryDetail>
ParameterTypeDescription
lotteryId requirednumberLottery ID.

Returns: A Promise of LotteryDetail.

enterLottery

Spends tokens to buy entries. Create one idempotency key for each purchase attempt and reuse it when you retry after an uncertain response. Needs a participant token.

Signature
enterLottery(lotteryId: number, options: EnterLotteryOptions): Promise<LotteryPurchase>
ParameterTypeDescription
lotteryId requirednumberLottery ID.
options.entryCount requirednumberEntries to buy, 1 to 100.
options.idempotencyKey requiredstringUnique key for this purchase attempt.

Returns: A Promise of LotteryPurchase: { id, lotteryId, entryCount, unitCostTokens, totalCostTokens, status, ticketNumbers, eligibilitySnapshot? }.

Example
import { createIdempotencyKey } from "@adquest/sdk";

const purchase = await client.enterLottery(4, {
  entryCount: 2,
  idempotencyKey: createIdempotencyKey(),
});

getMyLotteryEntries

Lists the participant’s entries and purchases for one lottery. Needs a participant token.

Signature
getMyLotteryEntries(lotteryId: number): Promise<MyLotteryEntriesResult>
ParameterTypeDescription
lotteryId requirednumberLottery ID.

Returns: A Promise of { entries, purchases, entryCount }.

getLotteryResults

Returns the winners once the lottery is completed. Before that, winners is empty. Needs a participant token.

Signature
getLotteryResults(lotteryId: number): Promise<LotteryResults>
ParameterTypeDescription
lotteryId requirednumberLottery ID.

Returns: A Promise of { lifecycleStatus, winners }.

getMyClaims

Lists the prizes the participant has won. Needs a participant token.

Signature
getMyClaims(): Promise<LotteryClaim[]>

Returns: A Promise of LotteryClaim[].

submitLotteryClaim

Submits the winner’s claim details. A submitted claim is not a promise that fulfillment is complete. Needs a participant token.

Signature
submitLotteryClaim(claimId: number, payload: SubmitClaimPayload): Promise<LotteryClaim>
ParameterTypeDescription
claimId requirednumberClaim ID from getMyClaims.
payload requiredRecord<string, unknown>The claim details the prize requires.

Returns: A Promise of the updated LotteryClaim.

Next steps

Something unclear, missing or wrong here? Tell us