ezsteam
Version:
A simply and lightweight package to interact with Steam API and convert IDs. Alpha testing.
42 lines (38 loc) • 1.38 kB
JavaScript
const steam = require('steam-web');
const axios = require('axios');
const { color } = require('terminal-color');
class Ezsteam {
constructor(apiKey) {
this.apiKey = apiKey;
var s = new steam({
apiKey: this.apiKey,
format: 'json'
});
}
async getSteam64(username) {
const route = 'http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=' + this.apiKey + '&vanityurl=' + username;
try {
const response = await axios.get(route);
return response.data.response.steamid;
}
catch (error) {
console.log(color.fg.red('[Ezsteam error]: Custom ID is wrong or doesn\'t exist.'))
console.log(error);
return;
}
}
async getCustom(steamID) {
const route = 'https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' + this.apiKey + '&steamids=' + steamID;
try {
const response = await axios.get(route);
const id = response.data.response.players[0].profileurl.slice(30, -1)
return id;
}
catch (error) {
console.log(color.fg.red('[Ezsteam error]: ID is wrong or doesn\'t exist.'))
console.log(error);
return;
}
}
}
module.exports = Ezsteam;