// XonixShop API — JavaScript SDK
class XonixShop {
constructor(apiKey) {
this.key = apiKey;
this.base = 'https://xonix.store/api/v1';
}
async req(method, path, body = null) {
const res = await fetch(this.base + path, {
method,
headers: {
'X-API-Key': this.key,
'Content-Type': 'application/json'
},
body: body ? JSON.stringify(body) : undefined
});
return res.json();
}
games() { return this.req('GET', '/games'); }
packages(code) { return this.req('GET', `/games/${code}/packages`); }
checkPlayer(game_code, player_id, server_id) {
return this.req('POST', '/game/check-player', {game_code, player_id, server_id});
}
buyGame(game_code, catalogue_name, player_id, server_id) {
return this.req('POST', '/game/order', {game_code, catalogue_name, player_id, server_id});
}
giftProducts(category_id) { return this.req('GET', `/gift/products${category_id?'?category_id='+category_id:''}`); }
buyGift(product_id, quantity = 1) { return this.req('POST', '/gift/buy', {product_id, quantity}); }
smmServices(platform) { return this.req('GET', `/smm/services${platform?'?platform='+platform:''}`); }
smmOrder(service_id, link, quantity) { return this.req('POST', '/smm/order', {service_id, link, quantity}); }
smmStatus(id) { return this.req('GET', `/smm/order/${id}`); }
orders(type = 'all', limit = 20) { return this.req('GET', `/orders?type=${type}&limit=${limit}`); }
me() { return this.req('GET', '/me'); }
}
// Ishlatish
const xs = new XonixShop('xs_your_api_key');
const info = await xs.me();
console.log(info.balance); // 20.00
// O'yin top-up
const check = await xs.checkPlayer('mlbb', '123456789', '3456');
if (check.valid) {
const order = await xs.buyGame('mlbb', '86 Diamonds', '123456789', '3456');
console.log(order.order_id);
}
// SMM buyurtma
const smm = await xs.smmOrder('XS-SMM-0001', 'https://t.me/channel', 1000);