Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheRealYT/6471fb59f2a5f374259056ce1492f39d to your computer and use it in GitHub Desktop.
Save TheRealYT/6471fb59f2a5f374259056ce1492f39d to your computer and use it in GitHub Desktop.
[FREE] Hamster Kombat playground promo keys generator. TWERK, MERGE, BIKE, CLONE, CUBE, TRAIN games.
const BASE_URL = 'https://api.gamepromo.io';
const games = {
TWERK: {
appToken: '61308365-9d16-4040-8bb0-2f4a4c69074c',
promoId: '61308365-9d16-4040-8bb0-2f4a4c69074c',
keysCount: 4,
delay: 20_000,
retry: 20_000,
},
MERGE: {
appToken: '8d1cc2ad-e097-4b86-90ef-7a27e19fb833',
promoId: 'dc128d28-c45b-411c-98ff-ac7726fbaea4',
keysCount: 4,
delay: 20_000,
retry: 20_000,
},
BIKE: {
appToken: 'd28721be-fd2d-4b45-869e-9f253b554e50',
promoId: '43e35910-c168-4634-ad4f-52fd764a843f',
keysCount: 4,
delay: 20_000,
retry: 20_000,
},
CLONE: {
appToken: '74ee0b5b-775e-4bee-974f-63e7f4d5bacb',
promoId: 'fe693b26-b342-4159-8808-15e3ff7f8767',
keysCount: 4,
delay: 120_000,
retry: 20_000,
},
CUBE: {
appToken: 'd1690a07-3780-4068-810f-9b5bbf2931b2',
promoId: 'b4170868-cef0-424f-8eb9-be0622e8e8e3',
keysCount: 4,
delay: 20_000,
retry: 20_000,
},
TRAIN: {
appToken: '82647f43-3f87-402d-88dd-09a90025313f',
promoId: 'c4480ac7-e178-4973-8061-9ed5b2e17954',
keysCount: 4,
delay: 120_000,
retry: 20_000,
},
};
async function fetchApi(path, authTokenOrBody = null, body = null) {
const options = {
method: 'POST',
cache: 'no-store',
};
if (typeof authTokenOrBody === 'string') {
options.headers = {
...(options.headers ?? {}),
authorization: `Bearer ${authTokenOrBody}`,
};
}
if ((authTokenOrBody !== null && typeof authTokenOrBody !== 'string') || body !== null) {
options.headers = {
...(options.headers ?? {}),
'content-type': 'application/json',
};
options.body = JSON.stringify(body ?? authTokenOrBody);
}
const url = `${BASE_URL}${path}`;
const res = await fetch(url, options);
if (!res.ok) {
const data = await res.text();
throw new Error(`${res.status} ${res.statusText}\n${data}`);
}
return await res.json();
}
async function login(clientId, gameId) {
return (await fetchApi('/promo/login-client', {
appToken: games[gameId].appToken,
clientId,
clientOrigin: 'android', // 'ios', 'deviceid' idk
}))['clientToken'];
}
async function hasCode(clientId, token, gameId) {
return (await fetchApi('/promo/register-event', token, {
promoId: games[gameId].promoId,
eventId: clientId,
eventOrigin: 'undefined',
}))['hasCode'] === true;
}
async function getPromoCode(token, gameId) {
return (await fetchApi('/promo/create-code', token, {
promoId: games[gameId].promoId,
}))['promoCode'];
}
module.exports = {
games,
fetchApi,
login,
hasCode,
getPromoCode,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment