1.0.2 • Published 3 months ago

skinport.js v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Skinport API Wrapper

npm version license

Easy to use, fully typed wrapper for interacting with Skinport API.

Installation

Install it from npm:

$ npm install skinport.js

Usage

ESM (ECMAScript Modules)

If you're using ESM ("type": "module" in package.json), you can directly import Skinport using import.

import Skinport from "skinport.js";

const skinport = new Skinport('clientId', 'clientSecret');

skinport.getItems();
skinport.getTransactions();
...

CommonJS (CJS)

If you're using CommonJS (require() based system), use await import().

(async () => {
  const { default: Skinport } = await import("skinport.js"); 

  const skinport = new Skinport('clientId', 'clientSecret');

  skinport.getItems();
  skinport.getTransactions();
  ...
})();

You don't need to pass clientId and clientSecret for methods which don't require authentication.

Initializing Websocket:

import Skinport from "skinport.js";

const skinport = new Skinport('clientId', 'clientSecret');

await skinport.initSocket();

const socket = skinport.socket;

Note: Trying to access .socket property before calling initSocket() will throw an error.

Documentation

API

const skinport = new Skinport('clientId', 'clientSecret');
  • clientId: string (optional) (required for secured methods)
  • clientSecret: string (optional) (required for secured methods)

Socket

Extends socket.io-client's Socket class. Will throw an error if accessed before calling initSocket().

await skinport.initSocket();
const socket = skinport.socket;

on(event, listener)

socket.on is io().on wrapper that includes typings support for Skinport websocket events.

socket.on(event, listener);
  • event: string (required)
    • "saleFeed"
  • listener: Function (required)

Event callback function has typings support.

socket.on("saleFeed", (data) => {
  /*
   * data extends SaleFeedData interface
   * 
   * Available properties: 
   * { 
   *      eventType: listed | sold,
   *      sales: any[],
   * }
   */
  const { eventType, sales } = data;
})

emit(event, data)

socket.emit is io().emit wrapper that includes typings support for Skinport websocket emitters.

socket.emit(event, data);
  • event: string (required)
    • "saleFeedJoin"
  • data: object (required)

Event emitter data has typings support.

socket.emit("saleFeedJoin", data);
/*
 * data extends SaleFeedJoinData interface
 * 
 * Available properties: 
 * { 
 *     appid: number,
 *     currency: string,
 *     locale: string
 * }
 */

initSocket()

Initializes the websocket


getItems(options)

Provides a list of items available on the marketplace, along with their associated metadata.

  • options: object (optional)

Authorization: Not required

PropertyTypeRequiredDescription
app_idnumberOptionalThe app_id for the inventory's game (default 730).
currencystringOptionalThe currency for pricing (default EUR - Supported: AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HRK, NOK, PLN, RUB, SEK, TRY, USD).
tradablebooleanOptionalIf true, it shows only tradable items on the market (default false).
const items = skinport.getItems({ app_id: 730, currency: "EUR", tradable: true });
console.log(items);

getSalesHistory(options)

Provides aggregated data for specific in-game items that have been sold on Skinport.

  • options: object (optional)

Authorization: Not required

PropertyTypeRequiredDescription
market_hash_namestringOptionalThe item's names, comma-delimited.
app_idnumberOptionalThe app_id for the inventory's game (default 730).
currencystringOptionalThe currency for pricing (default EUR - Supported: AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HRK, NOK, PLN, RUB, SEK, TRY, USD).
const salesHistory = skinport.getSalesHistory({ market_hash_name: "Glove Case,★ Karambit | Slaughter (Minimal Wear)", app_id: 730, currency: "EUR" });
console.log(salesHistory);

getOutOfStock(options)

Provides information about in-game items that are currently out of stock on Skinport.

  • options: object (optional)

Authorization: Not required

PropertyTypeRequiredDescription
app_idnumberOptionalThe app_id for the inventory's game (default 730).
currencystringOptionalThe currency for pricing (default EUR - Supported: AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HRK, NOK, PLN, RUB, SEK, TRY, USD).
const outOfStock = skinport.getOutOfStock({ app_id: 730, currency: "EUR" });
console.log(outOfStock);

getTransactions(options)

Retrieves a paginated list of user account transactions, including details.

  • options: object (optional)

Authorization: Required

PropertyTypeRequiredDescription
pagenumberOptionalPagination Page (default 1).
limitnumberOptionalLimit results between 1 and 100 (default 100).
orderstringOptionalOrder results by asc or desc (default desc).
const salesHistory = skinport.getSalesHistory({ market_hash_name: "Glove Case,★ Karambit | Slaughter (Minimal Wear)", app_id: 730, currency: "EUR" });
console.log(salesHistory);
1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago