1.1.3 • Published 2 years ago

csgoempire-api v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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)

OptionTypeDefault ValueDescription
fnFunction?-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.

OptionTypeDefault ValueDescription
----
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.

OptionTypeDefault ValueDescription
----
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.

OptionTypeDefault ValueDescription
----
empire.getActiveAuctions().then(res => {
    ...
})

You can find the response Object interface here


updateSettings

Used to update your tradelink and/or Steam API key

OptionTypeDefault ValueDescription
dataObject-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.

OptionTypeDefault ValueDescription
invalidbooleanfalseFilters 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

OptionTypeDefault ValueDescription
----
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

OptionTypeDefault ValueDescription
dataObject-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.

OptionTypeDefault ValueDescription
deposit_idnumber-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

OptionTypeDefault ValueDescription
deposit_idnumber-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

OptionTypeDefault ValueDescription
pagenumber-The page to fetch the data from
per_pagenumber-The ammount of items to be fetched per page
optionsObject?-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

OptionTypeDefault ValueDescription
deposit_idnumber-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.

OptionTypeDefault ValueDescription
deposit_idnumber-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.

OptionTypeDefault ValueDescription
deposit_idnumber-The deposited item's id
bid_valuenumber-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

OptionTypeDefault ValueDescription
pagenumber-The page to fetch the data from
per_pagenumber?15The 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

OptionTypeDefault ValueDescription
seednumber-The seed to fetch the data from
empire.getHistory(2543).then(res => {
    ...
})

You can find the response Object interface here

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago