Skip to content

Instantly share code, notes, and snippets.

@petersvp
Created February 3, 2021 20:30
Show Gist options
  • Select an option

  • Save petersvp/270f7d5d7d548448f4897586a0d389c0 to your computer and use it in GitHub Desktop.

Select an option

Save petersvp/270f7d5d7d548448f4897586a0d389c0 to your computer and use it in GitHub Desktop.
Batch Query Steam Keys for activation on SteamWorks
// 1. GO TO SteamWorks, into the Query CD Key page, here: https://partner.steamgames.com/querycdkey/
// 2. Fill in your keys below:
// 3. Go to DevTools, Console, and paste all of this here there!
// 4. Report will be printed to the console.
keys = `
0ZQR4-N0H7K-AEJ77
D05V5-P47AP-4ET3Q
GGJZ5-ZN0BR-F74C5
FWZP4-2IXHB-GYV3A
`
var keylist = keys.split("\n");
keylist.forEach(key => {
if(key.length<17) return;
function reqListener () {
let body = this.responseText;
let result = body.split('<h2>Activation Details</h2>')[1];
if (!result && !err) {
console.log('Error quering CD Key ' + key);
}
result = result.split('</table>')[0];
result = result.match(/<td>.*<\/td>/g);
result = result.map(function (line) {
return line.replace(/<[^>]*>/g, '');
});
let line = [key, (result[0] === 'Activated') ? '"' + result[1] + '"' : result[0]].join('\t');
console.log(line);
}
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://partner.steamgames.com/querycdkey/cdkey?cdkey="+key+"&method=Query");
oReq.send();
});
@AumCoin
Copy link

AumCoin commented Jan 27, 2025

Do I need to be signed up as a developer and have a paid developer account? Will this work with any key or just keys for my own games?

@petersvp
Copy link
Author

Yes, and the developer account must have access to the game you are querying too.

@hydrok
Copy link

hydrok commented Mar 20, 2025

If you need to add a delay for the purpose of rate limiting each request, try this code. I wrapped the original code in a setTimeout() and var interval is the amount of time (in ms) to delay. Thanks again for this solution!


keys = `
0ZQR4-N0H7K-AEJ77
D05V5-P47AP-4ET3Q
GGJZ5-ZN0BR-F74C5
FWZP4-2IXHB-GYV3A
`

    var keylist = keys.split("\n");
	var interval = 1000;

keylist.forEach((key, i) => {
	setTimeout(() => {	
		if (key.length < 17)
			return;
		function reqListener() {
			let body = this.responseText;
			let result = body.split('<h2>Activation Details</h2>')[1];
			if (!result && !err) {
				console.log('Error quering CD Key ' + key);
			}
			result = result.split('</table>')[0];
			result = result.match(/<td>.*<\/td>/g);
			result = result.map(function (line) {
				return line.replace(/<[^>]*>/g, '');
			});
			let line = [key, (result[0] === 'Activated') ? '"' + result[1] + '"' : result[0]].join('\t');
			console.log(line);
		}
		var oReq = new XMLHttpRequest();
		oReq.addEventListener("load", reqListener);
		oReq.open("GET", "https://partner.steamgames.com/querycdkey/cdkey?cdkey=" + key + "&method=Query");
		oReq.send();
	}, i * interval);
});

@petersvp
Copy link
Author

petersvp commented Mar 20, 2025 via email

@bfmmdev
Copy link

bfmmdev commented Apr 7, 2025

Getting errors expecting expecting semicolon before error.

What am I doing wrong?

EDIT: Clear console totally before running the script. Yes, this includes deleting the precurors "allow pasting" and all that.

@Goury
Copy link

Goury commented Apr 7, 2025

What am I doing wrong?

Not telling us the exact and whole error

@bfmmdev
Copy link

bfmmdev commented Apr 7, 2025

Doesn't matter what the issue is because I posted the solution for the issue I was running into. TLDR; ensure the console is completely empty before running the script.

@ThomazDiniz
Copy link

Just wanted to say thank you, I've used your code to make one that returns a list of not yet used keys.

@heintzer
Copy link

This is fantastic, thank you so much. Kinda insane Steamworks doesn't just spit out status of keys in the CSV when you download batches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment