Public
Edited
Jan 1, 2023
Insert cell
Insert cell
oauth = import("https://unpkg.com/oauth4webapi@2.0.6/build/index.js?module")
Insert cell
authenticationURL = {
// redirect user to as.authorization_endpoint

const authorizationUrl = new URL("https://steamcommunity.com/openid/login");
//authorizationUrl.searchParams.set("client_id", client.client_id);
authorizationUrl.searchParams.set("redirect_uri", "example.org");
authorizationUrl.searchParams.set("response_type", "code");
authorizationUrl.searchParams.set("scope", "openid email");
return authorizationUrl.toString();
}
Insert cell
htl.html`<a href=${authenticationURL} target="_blank">Login with Steam`
Insert cell
gameid = "582270"
Insert cell
url = {
const url = new URL(
"https://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v2/"
);
url.searchParams.set("gameid", gameid);
return url.toString();
}
Insert cell
{
const response = await fetch(url);
/** @type {{name: string, percent: number}[]} */
const achievements = await response.json();
return achievements;
}
Insert cell
key = "key"
Insert cell
steamid = "natpbs"
Insert cell
userAchievementsURL = {
const url = new URL(
"https://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v1/"
);
url.searchParams.set("key", key);
url.searchParams.set("steamid", steamid);
url.searchParams.set("appid", gameid);
return url.toString();
}
Insert cell
{
const response = await fetch(userAchievementsURL);
/** @type {{name: string, percent: number}[]} */
const json = await response.json();
return json;
}
Insert cell
$ = require("jquery@3.6.3/dist/jquery.js")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more