Great catch!
You are absolutely correct :
The /v1/items REST endpoint is not real-time and is rate-limited.
Skinport’s real-time listings are delivered via a WebSocket (using Socket.IO and msgpack ), as seen on their website and in their API docs .
To build a true sniper (instant deal detection), you must:
Connect to Skinport’s Socket.IO endpoint,
Parse incoming msgpack-encoded messages,
Filter for new/updated items,
Compare with Buff163,
Optionally auto-buy.
Below is a Chrome extension background script that:
Connects to Skinport’s Socket.IO WebSocket,
Decodes msgpack messages,
Filters for new/updated items,
Compares with Buff163,
Notifies you (and can auto-buy if you wish).
Note:
Chrome extensions can use socket.io-client and msgpack-lite via CDN or as bundled scripts.
You’ll need to add these libraries to your extension folder and reference them in your background script.
1. Add Libraries
Download and place these in your extension folder:
socket.io.min.js (from cdn )
msgpack.min.js (from cdn )
Update your manifest.json to allow these scripts in your background page (or bundle them).
2. Example: background.js (WebSocket, msgpack, Buff163, autobuy)
js Copy code
// background.js
// Load socket.io and msgpack
importScripts('socket.io.min.js', 'msgpack.min.js');
const BUFF_URL = 'https://prices.csgotrader.app/latest/buff163.json';
const SKINPORT_WS = 'wss://ws.skinport.com/socket.io/?EIO=4&transport=websocket';
let buffCache = {};
let userConfig = {
minPrice: 0,
maxPrice: 500,
discount: 15,
currency: 'EUR',
running: false
};
let socket = null;
// Load user config
chrome.storage.sync.get(['config'], data => {
if (data.config) userConfig = data.config;
});
// Listen for popup/options changes
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (msg.type === 'updateConfig') {
userConfig = { ...userConfig, ...msg.payload };
chrome.storage.sync.set({ config: userConfig });
sendResponse({ ok: true });
} else if (msg.type === 'toggleRunning') {
userConfig.running = msg.payload;
chrome.storage.sync.set({ config: userConfig });
if (userConfig.running) startSocket();
else stopSocket();
sendResponse({ ok: true });
}
});
// Fetch Buff163 prices every 10 minutes
async function refreshBuff() {
try {
buffCache = await fetch(BUFF_URL).then(r => r.json());
} catch (e) {
console.error('Buff163 fetch error', e);
}
}
refreshBuff();
setInterval(refreshBuff, 10 * 60 * 1000);
// Start/stop socket
function startSocket() {
if (socket) return;
socket = io('https://ws.skinport.com', {
transports: ['websocket'],
path: '/socket.io',
reconnection: true
});
socket.on('connect', () => {
console.log('Skinport WS connected');
// Subscribe to CS:GO (730) listings
socket.emit('subscribe', { appId: 730, currency: userConfig.currency });
});
socket.on('listing', data => {
// Data is msgpack encoded
let decoded;
try {
decoded = msgpack.decode(new Uint8Array(data));
} catch (e) {
console.error('msgpack decode error', e);
return;
}
handleListing(decoded);
});
socket.on('disconnect', () => {
console.log('Skinport WS disconnected');
socket = null;
});
}
function stopSocket() {
if (socket) {
socket.disconnect();
socket = null;
}
}
// Handle new/updated listing
function handleListing(item) {
// item: { market_hash_name, price, item_id, ... }
if (!item || !item.market_hash_name || !item.price) return;
if (item.price < userConfig.minPrice || item.price > userConfig.maxPrice) return;
const buff = buffCache[item.market_hash_name];
if (!buff || !buff.sell_min_price) return;
// Convert Buff price to EUR if needed (Buff is CNY)
// You may want to fetch CNY->EUR rate, here we use a fixed rate for demo
const CNY_EUR = 0.13;
const buffPriceEUR = Number(buff.sell_min_price) * CNY_EUR;
const diffPct = ((buffPriceEUR - item.price) / buffPriceEUR) * 100;
if (diffPct < userConfig.discount) return;
// Notify or auto-buy
tryAutoBuy(item, buffPriceEUR, diffPct);
}
// Try auto-buy
async function tryAutoBuy(item, buffPrice, diffPct) {
const { apiKey, autoBuy } = await chrome.storage.local.get(['apiKey', 'autoBuy']);
let bought = false;
if (apiKey && autoBuy) {
const url = `https://api.skinport.com/v1/items/${item.item_id}/buy`;
const body = JSON.stringify({ price: item.price });
const resp = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body
});
bought = resp.ok;
}
pushNotification(item, buffPrice, diffPct, bought);
}
// Notify
function pushNotification(item, buffPrice, diffPct, bought) {
chrome.notifications.create('', {
type: 'basic',
iconUrl: 'icons/icon48.png',
title: bought ? '✅ BOUGHT!' : '💰 Deal found!',
message:
`${item.market_hash_name}\n` +
`Skinport: ${item.price} EUR\n` +
`Buff163: ${buffPrice.toFixed(2)} EUR\n` +
`Discount: ${diffPct.toFixed(2)}%`
});
}
// Start socket if running
if (userConfig.running) startSocket();
3. Manifest changes
Add to your manifest.json:
json Copy code
"background": {
"service_worker": "background.js"
},
"web_accessible_resources": [
{
"resources": ["socket.io.min.js", "msgpack.min.js"],
"matches": ["<all_urls>"]
}
],
"permissions": [
"storage",
"notifications",
"https://api.skinport.com/*",
"https://prices.csgotrader.app/*"
],
"host_permissions": [
"https://api.skinport.com/*",
"https://prices.csgotrader.app/*"
]
4. Currency conversion
Buff163 prices are in CNY.
You should fetch a live CNY→EUR rate (e.g. from exchangerate.host) and cache it hourly.
For demo, a fixed rate is used.
To improve:
Add a function to fetch and cache the rate.
5. Improvements (as you requested)
Exponential backoff : Socket.IO handles reconnection.
Buff163 cache : Only refresh every 10 minutes.
Currency conversion : Add live rate fetch.
Sound alert : Add chrome.runtime.sendMessage to popup to play sound.
Telegram webhook : Add a POST to your bot in tryAutoBuy.
Show live table in popup : Store last N deals in chrome.storage.local, display in popup.
Content script fallback : If no API key, send message to content script to click "Buy" on skinport.com.
6. Final notes
This is a template ; you’ll need to adapt the exact event names and data structure as Skinport may change their protocol.
You may need to inspect the actual WebSocket traffic (using browser devtools) to confirm the event names and payloads.
Test with a throwaway account first!
Never share your API key.
If you want a full working ZIP with all files, let me know!
Or if you want a specific feature (e.g. Telegram, sound, live table), just ask!