This module provides easy interaction with the OPSkins ExpressTrade API. It provides a basic schema of the API to perform simple checks on the required inputs, and it automatically adds the 2FA token if required.
All you need to run a bot is your API key and the secret of your 2FA registered with your OPSkins account.
npm i expresstrade --save
var ExpressTrade = require('expresstrade')
var ET = new ExpressTrade({
apikey: 'Your OPSkins API Key',
twofactorsecret: 'Your OPSkins 2FA Secret',
pollInterval: 5000
})
ET.IUser.GetInventory((err, body) => {
// ...
})
ET.ITrade.SendOfferToSteamId({steam_id: '76561197982275081', items: '1234,5678'}, (err, body) => {
// ...
})
ET.on('offerReceived', (_offer) => {
console.log(_offer.id)
ET.ITrade.CancelOffer({offer_id: _offer.id})
})
You can either address the methods as object properties like this:
ET.IUser.GetInventory((err, body) => {
// ...
})
or address the path like this:
ET.request('IUser/GetInventory', ((err, body) => {
// ...
})
The required methods are saved in the API schema and node-expresstrade handles the conversion for GET (query string) and POST (form) on its own.
node-expresstrade accepts any JSON object containin the data.
If pollInterval
is set, node-expresstrade will poll for changes. If any new or changed offers are detected, an event will be emitted.
event
- The event typeoffer
- A Standard Trade Offer Object
Emitted on any event.
offer
- A Standard Trade Offer Object
Emitted when an offer has been sent out. The offer is active and the recipient can accept it to exchange the items.
offer
- A Standard Trade Offer Object
Emitted when an offer was received. The offer is active and you can accept it to exchange the items.
offer
- A Standard Trade Offer Object
Emitted when an offer has been accepted. The recipient accepted the offer and items were exchanged.
offer
- A Standard Trade Offer Object
Emitted when an offer has expired. The offer expired from inactivity.
offer
- A Standard Trade Offer Object
Emitted when an offer was cancelled. The sender cancelled the offer.
offer
- A Standard Trade Offer Object
Emitted when an offer has been declined. The recipient declined the offer.
offer
- A Standard Trade Offer Object
Emitted when an offer is no longer valid. One of the items in the offer is no longer available/eligible so the offer was cancelled automatically.
offer
- A Standard Trade Offer Object
Emitted when an offer has a pending case opening. The trade offer was initiated by a VCase site and it's awaiting ETH confirmations. The vKeys have been removed from the user iventory but may be restored on error later.
offer
- A Standard Trade Offer Object
Emitted when an offer for a case opening has expired. The trade offer was initiated by a VCase site and there was an error opening the case due to backend issues. No items should have been exchanged.
offer
- A Standard Trade Offer Object
Emitted when an offer for a case opening failed. The trade offer was initiated by a VCase site and VGO was unable to generate items on the blockchain, so the vKeys have been refunded.