API Quick Start
This guide makes two server-side requests:
- Load the platform identity and theme.
- Load the first page of published games.
Prepare a request helperโ
Store the access values in your server environment. The example requires Node.js 18 or newer.
const apiUrl = process.env.GAME_PLATFORM_API_URL ??
'https://api.gamepush.com/gs/api/graphql';
const apiKey = process.env.GAME_PLATFORM_API_KEY;
const platformId = process.env.GAME_PLATFORM_ID;
if (!apiKey || !platformId) {
throw new Error('Missing GamePush platform credentials');
}
async function requestGamePush(query, variables = {}) {
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Game-Platform-Api-Key': apiKey,
'X-Game-Platform-ID': platformId,
},
body: JSON.stringify({ query, variables }),
});
if (!response.ok) {
throw new Error(`GamePush API returned HTTP ${response.status}`);
}
const payload = await response.json();
if (payload.errors?.length) {
throw new Error(payload.errors[0].message);
}
if (payload.data.result.__typename === 'Problem') {
throw new Error(payload.data.result.message);
}
return payload.data.result;
}
Load the platform configurationโ
PlatformFetchGamePlatform uses the platform identified by the request headers.
query PlatformConfig($lang: Lang) {
result: PlatformFetchGamePlatform {
__typename
... on Problem {
message
}
... on GamePlatform {
id
name(lang: $lang)
title(lang: $lang)
icon
mainPageId
supportedLanguages
styles {
colors {
primary
accent
contentBackground
}
}
}
}
}
Variables:
{
"lang": "EN"
}
Pass this operation and its variables to requestGamePush. The helper returns the successful GamePlatform branch or throws an error for Problem.
A successful result has the following shape:
{
"__typename": "GamePlatform",
"id": 42,
"name": "Example Games",
"title": "Play online games",
"icon": "https://cdn.example.com/platform-icon.webp",
"mainPageId": "home",
"supportedLanguages": ["EN", "RU"],
"styles": {
"colors": {
"primary": "#7c3aed",
"accent": "#f59e0b",
"contentBackground": "#ffffff"
}
}
}
Load published gamesโ
Use FetchGamesOnGamePlatform with isPublished: true. The maximum page size is 25.
query PublishedGames($input: FetchGamesOnGamePlatformInput!, $lang: Lang) {
result: FetchGamesOnGamePlatform(input: $input) {
__typename
... on Problem {
message
}
... on GameViewsList {
count
items {
id
name(lang: $lang)
description(lang: $lang)
icon(lang: $lang)
cover(lang: $lang)
platformUrl(lang: $lang)
rating
}
}
}
}
Variables:
{
"lang": "EN",
"input": {
"gamePlatformId": 42,
"withMetrics": false,
"isPublished": true,
"limit": 12,
"offset": 0
}
}
Use the selected platform's ID both for X-Game-Platform-ID and for gamePlatformId. The API key determines the server-side platform access context. Increase offset by limit to load the next page. With withMetrics: false, GameViewsList.count is the number of items in the current response, not the total number of matching games. Stop when items.length is less than limit.
A successful response has this shape:
{
"data": {
"result": {
"__typename": "GameViewsList",
"count": 1,
"items": [
{
"id": 101,
"name": "Example Game",
"description": "A short game description",
"icon": "https://cdn.example.com/game.webp",
"cover": "https://cdn.example.com/game-cover.webp",
"platformUrl": "https://games.example.com/game/example-game",
"rating": 8.4
}
]
}
}
}
Next stepโ
Render each item as a game card and use platformUrl as its site link. Continue with Platform and Games for the complete configuration, content, and metrics queries.