Build a CS2 price Discord bot
A /price command that answers with the cheapest marketplace and a link to the full chart on Skinstrack. Built with discord.js v14 and the official skinstrack SDK.
- Stack
- Node.js 18+, discord.js v14
- Plan
- Paid (Standard and up)
- Data
- 34+ marketplaces, refreshed ~15 min
- 1
Get a free Skinstrack API key
Sign in with Steam on skinstrack.com and create a key in the dashboard. The free plan gives 50 requests a month on Steam prices with no card. Paid plans from $24.99 a month unlock all 34+ marketplaces. Keep the key in an environment variable, never in source code.
terminalbashexport SKINSTRACK_API_KEY=your-api-key - 2
Install dependencies
Create a bot in the Discord developer portal, copy its token and application id, then install the two packages.
terminalbashnpm install discord.js skinstrack - 3
Write the bot
The bot registers /price on startup, looks the skin up with getItem and replies with an embed. The skinstrack_url field in the response links straight to the skin's page with history and alerts.
bot.mjsjsimport { Client, EmbedBuilder, Events, GatewayIntentBits, REST, Routes, SlashCommandBuilder } from "discord.js"; import { NotFoundError } from "skinstrack"; import { SkinstracksV2 } from "skinstrack/v2"; const skinstrack = new SkinstracksV2({ apiKey: process.env.SKINSTRACK_API_KEY }); const command = new SlashCommandBuilder() .setName("price") .setDescription("Live CS2 skin price across 34+ marketplaces") .addStringOption((o) => o.setName("skin").setDescription("e.g. AK-47 | Redline (Field-Tested)").setRequired(true)); const rest = new REST().setToken(process.env.DISCORD_TOKEN); await rest.put(Routes.applicationCommands(process.env.DISCORD_APP_ID), { body: [command.toJSON()] }); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.on(Events.InteractionCreate, async (interaction) => { if (!interaction.isChatInputCommand() || interaction.commandName !== "price") return; await interaction.deferReply(); try { const item = await skinstrack.getItem(interaction.options.getString("skin", true)); const top = [...item.prices].sort((a, b) => a.price - b.price).slice(0, 5); const embed = new EmbedBuilder() .setTitle(item.market_hash_name) .setURL(item.skinstrack_url) .setDescription(top.map((p) => `**${p.provider}** $${p.price.toFixed(2)}`).join("\n")) .setFooter({ text: "Prices by Skinstrack" }); await interaction.editReply({ embeds: [embed] }); } catch (error) { const message = error instanceof NotFoundError ? "Skin not found." : "Price lookup failed."; await interaction.editReply(message); } }); client.login(process.env.DISCORD_TOKEN); - 4
Run it
Set the three environment variables and start the bot. Each /price call uses one API request.
terminalbashexport DISCORD_TOKEN=... DISCORD_APP_ID=... SKINSTRACK_API_KEY=... node bot.mjs
Ready to run it?
Get a Skinstrack API key in a minute. Free tier: 50 requests per month on Steam prices, no card required.