Hey, I am looking for a good way to convert Steam AppID to SteamGifts GameID for a project I am working on.
Is there maybe some API perhaps?
The only way I currently see how to do this, is to convert the Steam AppID to the game title and then lookup the game title on steamgifts to get the GameID. But this method is pretty sloppy. I hope there is a better way.
Thanks

Edit:
I made an API that returns all appid's with their corresponding gameid.

7 years ago*

Comment has been collapsed.

I'm confused. As far as I know, SG uses the same game IDs as Steam.
Are you talking about something else?

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

Hmm, too bad.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

It would be great if you could scrape all games from SteamGifts and put them in a database, so we can use them with your API.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

True, but I see no other way. BTW, check below.

7 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 4 years ago.

7 years ago
Permalink

Comment has been collapsed.

Okay, so I coded a scraper in JavaScript, which works pretty well.

var db = "";
var terminate = false;

function start() {
    for (var i = 0; i < 256; i++) {
        collect(String.fromCharCode(i), 1);
    }
}

function stop() {
    terminate = true;
}

function show() {
    console.log(db.slice(0, -1), db.slice(0, -1).split(",").map(function(x){return x.split(":");}));
}

function collect(query, page) {
    if (!terminate) {
        var data = { search_query: query, page_number: page, do: "autocomplete_game" };
        $.ajax({
            url: "/ajax.php",
            method: "POST",
            dataType: "json",
            data: data,
            success: function(json) {
                var html = json.html;
                if (html.length > 0) {
                    $("[data-autocomplete-id]", html).each(function() {
                        if ($(this).find("[href*='//store.steampowered.com/app/']").length > 0) {
                            var gameid = $(this).attr("data-autocomplete-id");
                            var appid = $(this).find("[href*='//store.steampowered.com/app/']").attr("href").split("/")[4];
                            var dbitem = appid + ":" + gameid;
                            if (db.indexOf(dbitem) == -1) {
                                db += dbitem + ",";
                                console.log("Added " + dbitem);
                            }
                        }
                    });
                    if ($(".fa-angle-right", html).length > 0) {
                        collect(query, page+1);
                    }
                }
            }
        });
    }
}

Run this code anywhere on SteamGifts, use start() to start scraping the data, use stop() to stop and use show() to show the data that was collected (format: appid:gameid). Here is data I collected for only running it a little while.

Edit:
Ran it a few hours and collected around 20K Game and DLC ID's.

7 years ago*
Permalink

Comment has been collapsed.

If anyone is interested I am hosting a public JSON file / API where you can find AppID's with their corresponding game id's.

7 years ago
Permalink

Comment has been collapsed.

Sign in through Steam to add a comment.