npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tormak/tauri-steamgriddb

v1.2.0

Published

A Tauri compatible wrapper for the SteamGridDB API.

Downloads

5

Readme

tauri-steamgriddb

A Tauri compatible wrapper for the SteamGridDB api.

Installation

npm install @tormak/tauri-steamgriddb

Getting Started

Get your API key

You can generate an API key on the SteamGridDB preferences page.

HTTP Scope

In your tauri.config.json add:

{
  "tauri": {
    "http": {
      "all": false, //can be true as well, doesn't matter
      "request": true,
      "scope": [
        "https://*.steamgriddb.com/api/*"
      ]
    },
  }
}

Require the library into your project.

import SGDB from "@tormak/tauri-steamgriddb";

Pass your API key into the constructor:

const client = new SGDB('your_api_key');

Optionally, you can pass an object with some settings:

const client = new SGDB({
    key: 'your_api_key',
    headers: {
        'X-Some-Header': 'Some Value',
    },
    baseURL: 'https://www.steamgriddb.com/api/v2'
});

Usage

Although these code examples use await, SteamGridDB can also be used with .then() and .catch().

  client.getGrids({type: 'game', id: 2254})
  .then((grids) => {
    console.log(grids);
  })
  .catch((error) => {
    console.error(error);
  });

Search for a game:

const games = await client.searchGame('Half-Life 2');
[
  {
    "id": 2254,
    "name": "Half-Life 2",
    "types": [
      "steam"
    ],
    "verified": true
  },
  {
    "id": 21207,
    "name": "Half-Life",
    "types": [
      "steam"
    ],
    "verified": true
  },
  {
    "id": 1417,
    "name": "Half-Life: Blue Shift",
    "types": [
      "steam"
    ],
    "verified": true
  },
  {
    "id": 3868,
    "name": "Half-Life: Source",
    "types": [
      "steam"
    ],
    "verified": true
  }
]

Get grids By Game ID

// 2254 = Game ID we got from searchGame()
const grids = await client.getGrids({type: 'game', id: 2254}); 
// 2254 = Game ID we got from searchGame()
const grids = await client.getGridsById(2254);

Get grids by Steam App ID

// Get grid by Steam App Id
// 220 = https://store.steampowered.com/app/220/HalfLife_2/
const grids = await client.getGrids({type: 'steam', id: 220});
// 220 = https://store.steampowered.com/app/220/HalfLife_2/
const grids = await client.getGridsBySteamAppId(220);

Filter styles:

const grids = await client.getGrids({type: 'game', id: 2590, styles: ['material','blurred']});
client.getGridsBySteamAppId(220, ['material','blurred'])
[
  {
    "id": 80,
    "score": 1,
    "style": "blurred",
    "url": "https://s3.amazonaws.com/steamgriddb/grid/f033ab37c30201f73f142449d037028d.png",
    "thumb": "https://s3.amazonaws.com/steamgriddb/thumb/f033ab37c30201f73f142449d037028d.png",
    "tags": [],
    "author": {
      "name": "EpicWolverine",
      "steam64": "76561198025674497",
      "avatar": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/76/764911aeb96ae312c2819780f4107396d3b5ac38.jpg"
    }
  },
  {
    "id": 120,
    "score": 1,
    "style": "blurred",
    "url": "https://s3.amazonaws.com/steamgriddb/grid/da4fb5c6e93e74d3df8527599fa62642.png",
    "thumb": "https://s3.amazonaws.com/steamgriddb/thumb/da4fb5c6e93e74d3df8527599fa62642.png",
    "tags": [],
    "author": {
      "name": "Tiederian",
      "steam64": "76561197997534033",
      "avatar": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/bc/bc893073b7e2e60ad412c6fd2af39d3204a5f26a.jpg"
    }
  }
]

Delete grids:

// Delete a grid
const success = await client.deleteGrids(80);
// Delete multiple grids
const success = client.deleteGrids([80,81,82,83]);

Handling errors:

SteamGridDB throws an custom RequestError when an error occurs, with the message altered to contain the message returned from SteamGridDB. You can access the response with error.response.

// Get grids for a game that doesn't exist
let grids;

try {
  grids = await SGDB.getGrids({dimensions: ["460x215", "920x430"], ...{type, id: 0}});
} catch (error) {
  console.log(error.message); // "Game not found."
  console.log(err.response.status); // 404
};
// Try to delete a grid you don't own
try {
  await client.deleteGrids(34312);
} catch (error) {
  console.log(error.message); // "This grid isn't yours."
  console.log(err.response.status); // 403
}