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 :)
With npm:
npm install csgoempire-api
With Yarn:
yarn add csgoempire-api
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.socketNote: Not running initSocket will result in a undefined socket instance
| Option | Type | Default Value | Description |
|---|---|---|---|
| fn | Function? | - | A callback function that gets executed when the socket is initialized and authenticated |
const empire = new CSGOEmpire(apiKey)- apiKey: string (required)
- webSocketEnabled: boolean (optional) (true by default)
Extends socket.io-client's class. Can be undefined if not initialized
const socket = empire.socketsocket.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
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
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
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
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
Deposit related methods
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
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
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
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
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 related methods
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
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
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
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
Other api methods
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
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