Skip to main content

Recipes

Common Prism queries. Each is POSTed to /v1/offers with your Authorization: Bearer <token> and Content-Type: application/json — see the Overview for the full request shape. Pass the player ID as a variable so the query is reusable.

Fetch offers for a player

query GetOffers($playerId: String!) {
offers(player_id: $playerId) {
id
name
total_payout_usd
}
}
{ "playerId": "user-123" }

Include creative details

Select nested fields to render the offer in your UI:

query GetOffersWithCreatives($playerId: String!) {
offers(player_id: $playerId) {
id
name
total_payout_usd
creatives {
name
description
}
}
}

Fetch a player's engaged offers

playerOffers returns the offers a player has already engaged with, both in progress and completed, most recently engaged first. Each goal carries its own completion state, so you can render partial progress on a multi-goal offer:

query GetPlayerOffers($playerId: String!, $after: String) {
playerOffers(player_id: $playerId, limit: 50, after: $after) {
offers {
id
name
status
started_at
availability
goals {
name
is_completed
completed_at
}
}
next_cursor
has_more
}
}
{ "playerId": "user-123" }

Two fields describe availability and progress, and they answer different questions. status is the player's progress, IN_PROGRESS or COMPLETED. availability is the state of the offer itself: an offer that has since been disabled or deleted still appears here, because a player who already started it can still finish it.

Paginate on has_more, not on the number of offers returned

A page can come back with fewer than limit offers and still not be the last page, so the length of offers is not an end-of-list signal. Loop until has_more is false, passing the previous response's next_cursor as after:

const pages = [];
let after = null;

do {
const response = await fetch("https://targeted-api.adgem.com/v1/offers", {
method: "POST",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: GET_PLAYER_OFFERS,
variables: { playerId: "user-123", after },
}),
});

const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);

pages.push(...data.playerOffers.offers);
after = data.playerOffers.next_cursor;
} while (after !== null);

Omit after on the first request. next_cursor is null on the final page, which is the same signal as has_more being false.

This list covers the last 120 days

playerOffers reports engagements from the last 120 days, measured from when the player engaged with the offer. Older engagements drop off the list, including completed ones, so treat it as a recent-activity view rather than a lifetime history. The same bound applies to the offer history shown in AdGem's own offerwall, so a player sees the same window in both places.

Prism also exposes a links query for a player's tracking links — select the fields you need on it the same way as offers.


GraphQL returns exactly the fields you request, so ask for only what you need. GraphQL is also introspective, so you can explore the available queries, fields, and types directly from any GraphQL client.