Skip to content

Preact Support + More API

Latest
Compare
Choose a tag to compare
@ybabts ybabts released this 26 Dec 23:56
· 4 commits to main since this release

Preact Support and More API calls

  • Fixes an issue with relative import paths
  • Adds 8 more API calls for Steam, including ResolveVanityURL and getSupportedAPIList (see below)
  • Refactored to allow for more extendibility
  • Added more enums, types, and data for Dota 2
  • Added common Preact components for Dota 2

ResolveVanityURL

This API call is pretty standard when building websites for end users, most people don't remember their SteamID unless they're freaks. So Steam allows you to set a vanity URL to make it easier to share your profile page. For example Gabe Newell's Steam ID is 22202 and the link to his Steam profile would be this.

https://steamcommunity.com/profiles/76561197960287930
But with a vanity URL, his profile is able to have this instead.
https://steamcommunity.com/id/GabeLoganNewell/

The only problem with this is that we can't use a vanity URL for our API calls, we have to use their actual Steam ID. Luckily there's an API call to resolve their vanity URL. You can call it using the following code.

import * as Steam from "https://deno.land/x/[email protected]/Steam/mod.ts";

const req = await Steam.resolveVanityURL('GabeLoganNewell');
const steamid = req.steamid;
// steamid: 76561197960287930

This will always return a SteamID64 formatted SteamID. So if you need to use SteamID32, you can then convert between other SteamIDs with the following snippet.

const steamid32 = Steam.normalizeSteamID(steamid).id32
// steamid32: 22202

Preact Support

Since this library is most useful for building a website that implements Steam's API calls, I figured it would be great to provide some basic components for assets like Hero Icons, Portraits, Abilities, Items etc. You can import them with the following snippet.

import * as Dota2React from "https://deno.land/x/[email protected]/Dota2/React/mod.ts"

Currently we have AbilityIcon, HeroIcon, HeroPortrait, and ItemIcon available. They all extend from HTMLImageElement so you can just treat them like any image apart from their provided properties. Here's an example of using them in another Preact component.

import { HeroPortrait, AbilityIcon } from "https://deno.land/x/[email protected]/Dota2/React/mod.ts"
import { HeroID, AbilityID } from "https://deno.land/x/[email protected]/Dota2/types.ts"

<div class="flex children:(m-4)">
  <HeroPortrait hero_id={HeroID.Enigma} />
  <AbilityIcon ability_id={AbilityID.enigma_malefice} />
  <AbilityIcon ability_id={AbilityID.enigma_demonic_conversion} />
  <AbilityIcon ability_id={AbilityID.enigma_midnight_pulse} />
  <AbilityIcon ability_id={AbilityID.enigma_black_hole} />
</div>

API calls added

  • Dota2.getTopLiveGame
  • Steam.getAppList
  • Steam.getAssetPrices
  • Steam.getNewsForApp
  • Steam.getSDRConfig
  • Steam.getServersAtAddress
  • Steam.getSupportedAPIList
  • Steam.resolveVanityURL

Full Changelog: v0.04...v0.05aa