Skip to content

Instantly share code, notes, and snippets.

@jonathonlui
Created December 27, 2016 00:49
Show Gist options
  • Save jonathonlui/be3f35d07a5694c79e7ffc0ecd2bd36f to your computer and use it in GitHub Desktop.
Save jonathonlui/be3f35d07a5694c79e7ffc0ecd2bd36f to your computer and use it in GitHub Desktop.
Get list of keys from Humble Bundle Library page
/*
* Run on https://www.humblebundle.com/home/library
* Global variable `gamekeys` is available on the Library page
*
*/
Promise.all(gamekeys.map(key => {
return new Promise((resolve, reject) => {
$.ajax({
url: `https://www.humblebundle.com/api/v1/order/${key}?all_tpkds=true`
}).done(data => resolve(data))
})
}))
.then(results => {
let keys = []
results.forEach(result => {
keys = keys.concat(result.tpkd_dict.all_tpks.map(tpk => {
return {
name: tpk.human_name,
key_type: tpk.key_type_human_name,
redeemed: tpk.redeemed_key_val
}
}))
})
return keys
})
.then(keys => keys.sort((a ,b) => (a.name < b.name) ? -1 : 1))
.then(keys => {
keys.forEach(key => {
console.log(`"${key.name}", ${key.key_type}, ${key.redeemed}`)
})
})
@Levvy055
Copy link

looks like gamekeys was removed

@Bluscream
Copy link

yeah, can we get an update?

@chadfurman
Copy link

FWIW I'm currently working on a GraphQL wrapper around the Humble Bundle API: https://github.com/chadfurman/humble-bundle-ebooks

It was originally targeted just at ebooks (hence the name), but should support any metadata that the HumbleBundle API spits out. This will include hashes etc. Please feel free to make requests in the issues section while I work on this.

Full Disclosure: This is somewhat of a long-term project, and I'm not sure when I'll be done but I'm doing my best so please be patient and respectful :) I expect Humble Bundle will eventually change their API, also, but I'm separating out the network layer which parses and stores data from the GQL resolvers which queries a local cache, so the majority of the code will be the same. Worst case, I'll have to start making raw requests for HTML and parsing it out with Beautiful Soup which I'd love to not have to do but we'll see how the cookie crumbles in the future. As it stands, they provide a really clean REST API and I hope they keep this option available!

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