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

csgoempire-api

v1.1.3

Published

The unofficial CSGOEmpire API JavaScript Wrapper

Downloads

6

Readme

Unofficial CSGOEmpire API Wrapper

The unofficial CSGOEmpire API JavaScript Wrapper

You can find the Official CSGOEmpire Api documentation here

You can also find the change log file here

This wrapper is not complete yet. If you feel like contributing, open a pull request proposing a change :)

Installation

With npm:

npm install csgoempire-api

With Yarn:

yarn add csgoempire-api

Usage

import { CSGOEmpire } from "csgoempire-api"

const empire = new CSGOEmpire(YOUR_API_KEY)

empire.getActiveTrades()
empire.getActiveAuctions()
...

Initializing websocket:

import { CSGOEmpire } from "csgoempire-api"

const empire = new CSGOEmpire(YOUR_API_KEY)

empire.initSocket((socket) => {
    socket.on("new_item", (data) => {
        // ...
    })
})

// empire.socket can be undefined
const socket = empire.socket

Note: Not running initSocket will result in a undefined socket instance

initSocket(fn)

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | fn | Function? | - | A callback function that gets executed when the socket is initialized and authenticated |

Documentation

Api

const empire = new CSGOEmpire(apiKey)
  • apiKey: string (required)
  • webSocketEnabled: boolean (optional) (true by default)

Socket

Extends socket.io-client's class. Can be undefined if not initialized

const socket = empire.socket

on(event, fn)

socket.on is a io().on wrapper that provides typings support for CSGOEmpire's events

socket.on(event, fn)
  • event: string (required)
    • "new_item"
    • "updated_item"
    • "auction_update"
    • "deleted_item"
    • "trade_status"
    • "timesync"
  • fn: Function (required)

Each event function has typings support.

socket.on("new_item", (data) => {
    /**
     * data extends NewItemSocketData interface
     * 
     * Available properties: 
     * { 
     *      id: number,
     *      name: string,
     *      ...
     * }
     */
    const { id, name } = data
})

You can check all events example responses here


getMetadata

Returns the user object, which is used to identify via websocket, as well as socket token (authorizationToken) & socket signature (signature) which are used to authenticate on websocket.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | - | - | - | - |

empire.getMetadata().then(res => {
    ...
})

You can find the response Object interface here


getActiveTrades

Returns an array of all items currently being deposited or withdrawn by this account. This does not include bids placed on active items until the auction ends.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | - | - | - | - |

empire.getActiveTrades().then(res => {
    ...
})

You can find the response Object interface here


getActiveAuctions

Returns an array of all auctions currently being bid on by this account.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | - | - | - | - |

empire.getActiveAuctions().then(res => {
    ...
})

You can find the response Object interface here


updateSettings

Used to update your tradelink and/or Steam API key

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | data | Object | - | An object containing a trade_url (required) and a steam_api_key (optional) |

empire.updateSettings().then(res => {
    ...
})

You can find the response Object interface here


Deposits

Deposit related methods

getCSGOInventory

Fetch your inventory from steam and caches it to the database for 1 hour.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | invalid | boolean | false | Filters invalid items, defaults to no filtering |

empire.getCSGOInventory().then(res => {
    ...
})

You can find the response Object interface here

getUniqueInfo

Get inspected unique info for items in user inventory. Examples include float/sticker data

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | - | - | - | - |

empire.getUniqueInfo().then(res => {
    ...
})

You can find the response Object interface here

createDeposit

Creates an item deposit

Notes: coin_value is in coin cents, so 100.01 coins is represented as 10001

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | data | Object | - | An object containing an array of items to deposit |

empire.createDeposit({
    items: [
        {
            "id": 3731677704,
            "custom_price_percentage": 32,
            "coin_value": 576811
        }
    ]
}).then(res => {
    ...
})

You can find the response Object interface here

cancelDeposit

Cancels processing deposit without any bids. Once a bid has been placed items are no longer eligible to be cancelled.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | deposit_id | number | - | The deposited item's id |

empire.cancelDeposit(28391470).then(res => {
    ...
})

You can find the response Object interface here

sellNow

Sells an on going auction item to the current auction highest bidder

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | deposit_id | number | - | The deposited item's id |

empire.sellNow(28391470).then(res => {
    ...
})

You can find the response Object interface here


Withdraw

Withdraw related methods

getListedItems

Get a list of all items listed on the withdrawals page

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | page | number | - | The page to fetch the data from | | per_page | number | - | The ammount of items to be fetched per page | | options | Object? | - | An object containing filtering options |

empire.getListedItems(1, 50, { sort: "asc" }).then(res => {
    ...
})

You can find the response Object interface here

getDepositorStats

Get the depositing users stats from a unique deposit ID

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | deposit_id | number | - | The deposited item's id |

empire.getDepositorStats(28391470).then(res => {
    ...
})

You can find the response Object interface here

createWithdrawal

Withdraw item directly if the auction has expired without being won.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | deposit_id | number | - | The deposited item's id |

empire.createWithdrawal(28391470).then(res => {
    ...
})

You can find the response Object interface here

placeBid

Place a bid on an auction.

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | deposit_id | number | - | The deposited item's id | | bid_value | number | - | The ammount to bid |

empire.placeBid(28391470, 60).then(res => {
    ...
})

You can find the response Object interface here


Misc

Other api methods

getSeeds

Get roulette seeds

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | page | number | - | The page to fetch the data from | | per_page | number? | 15 | The ammount of items to be fetched per page |

empire.getSeeds(1, 20).then(res => {
    ...
})

You can find the response Object interface here

getHistory

Returns rolls history

| Option | Type | Default Value | Description | | :----: | :--: | :----: | :----: | | seed | number | - | The seed to fetch the data from |

empire.getHistory(2543).then(res => {
    ...
})

You can find the response Object interface here