steam-api-sdk
v1.6.1
Published
A Node.js wrapper for the Steam Web API, includes many tools for fetching and parsing data from the Steam Web API.
Downloads
167
Maintainers
Readme
Steam-API-SDK
This package includes many functions to use along with the Steam API. It is a work in progress and will be updated over time. Currently it includes some basic and advanced functions to fetch data about users.
Installation
Install from npm using the following command:
npm install steam-api-sdk
or if you are using yarn:
yarn add steam-api-sdk
Getting Started
You have 2 ways to use this package:
• By using an .env file:
First add an environment variable to your .env file with the name STEAM_API_KEY
and the value of your Steam API key.
You can get your Steam API key from here.
.env
example:
STEAM_API_KEY = 'web-api-key';
• By passing the API key as a parameter to the config file
Import config from the package and pass your Steam API key as a parameter to the config function.
import { config } from 'steam-api-sdk' // or const steam = require -> steam.config
config.apiKey = 'web-api-key'
Then import the package into your project:
const steam = require('steam-api-sdk')
Or if you are using ES6:
import steam from 'steam-api-sdk'
Thats all :)
Functions
Convert Steam32 to Steam64 ID ([U:1:XXX] ➜ 7656119XXX)
import { From32To64 } from 'steam-api-sdk'
const steam64 = From32To64([U:1:XXX]) // 7656119XXX
Convert Steam64 to Steam32 ID (7656119XXX ➜ [U:1:XXX])
import { From64To32 } from 'steam-api-sdk'
const steam32 = From64To32('7656119XXX') // [U:1:XXX]
Convert Steam64 to Steam ID (7656119XXX ➜ STEAM_0:0:XXX) Array
import { From64ToSteamID } from 'steam-api-sdk'
const steamIds = From64ToSteamID('7656119XXX')
// Array of: [STEAM_0:0:XXX, STEAM_0:1:XXX]
Convert Steam64 to a user object (7656119XXX ➜ object details about the user)
import { From64ToUser } from 'steam-api-sdk'
const user = From64ToUser('7656119XXX')
// User Object
const user = From64ToUser(['7656119XXX', '7656119XXX', '7656119XXX'])
// User Object Array
Please note that you can use string OR array of strings that contains the user's Steam64 id. you should use that if you want to get multiple users at once without getting rate limited by Steam and also reduce the response time! (instead of sending 50 requests for 50 users, it will send 1 request for 50 users = 50x faster)
Convert Steam64 to a user object (7656119XXX ➜ object details about the user)
import { GetSteamUser } from 'steam-api-sdk'
const user = GetSteamUser('https://steamcommunity.com/id/NXTShiNxz/')
// profile url -> User Object
const user = GetSteamUser('http://steamcommunity.com/profiles/76561198998419941')
// profile url (2) -> User Object
const user = GetSteamUser('STEAM_0:0:454468949')
// profile url (2) -> User Object
const user = GetSteamUser('76561198869203626')
// profile url (2) -> User Object
Convert Steam ID to steam64 ID (STEAM_0:0:454468949 ➜ 76561198869203626)
import { SteamIDToSteam64 } from 'steam-api-sdk'
const steam64 = SteamIDToSteam64('STEAM_0:0:454468949')
// 76561198869203626
Convert Steam Profile URL to steam64 ID (https://steamcommunity.com/id/XXX/ ➜ 76561198869203626)
import { VanityUrlTo64 } from 'steam-api-sdk'
const steam64 = VanityUrlTo64('https://steamcommunity.com/id/XXX/')
// 76561198869203626
Contributing
If you want to contribute to this package, please feel free to do so by opening a pull request with your changes. Currently this package is in development and will be updated over time. We are looking for contributors to help us improve this package by adding new functions and improving the existing ones.
Issues & Questions
If you have any questions or suggestions, please open an issue and I will get back to you as soon as possible.