danielmagacf / steam-trade
Installs: 521
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/danielmagacf/steam-trade
Requires
- guzzlehttp/guzzle: ^7.0
This package is auto-updated.
Last update: 2025-09-27 20:49:13 UTC
README
#this package is just a wrapper
To install
composer require danielmagacf/steam-trade
To use
Danielmagacf\SteamTrade\SteamTrader::get($sessionId, $cookiesArray);
php-steam-tradeoffers
Steam Trade Offers library for PHP (based on node.js library by Alex7Kom)
All the same functions as in Alex7Kom library
Note: By using this library you automatically agree to Steam API Terms of Use
Installation
require_once 'classes/steam.class.php'
Usage
Instantiate a steam object...
$steam = new SteamTrade();
...then setup session:
$steam->setup('sessionID', 'cookies');
This setup will automatically register and retrieve Steam API key for you.
Methods
The first param for all methods (except setup) is an associative array of options.
setup(sessionId, cookies)
As noted above, this method is used to setup a web session. It also tries to retrieve Web API key.
Options:
sessionIDis a valid web session ID.webCookieis an array of cookies.
If failed to retrieve Web API key due to limited account, setup will throw the error.
loadMyInventory(options)
Loads your inventory for the given app and context. For example, use 440 and 2 for TF2 and 570 and 2 for Dota 2.
Options:
appIdis the Steam AppIDcontextIdis the inventory context Idlanguage(optional) is the language for item descriptionstradableOnly(optional) is a boolean flag that defaults totrueto return tradable items only
loadPartnerInventory(options)
Loads your partner inventory for the given app and context.
Options:
partnerSteamIdis the SteamID of the trade partnerappIdis the Steam AppIDcontextIdis the inventory context IdtradeOfferId(optional) is needed to load private inventory of the trade partner for received trade offerlanguage(optional) is the language for item descriptions
makeOffer(options)
Makes a trade offer to the partner.
Options:
partnerAccountIdorpartnerSteamId, you need only one of those.accessToken(optional) is a token from the public Trade URL of the partner.itemsFromMeare the items you will lose in the trade.itemsFromThemare the items you will receive in the trade.counteredTradeOffer(optional) is the ID to a trade offer you are countering.message(optional) is a message to include in the offer.
itemsFromMe and itemsFromThem both are arrays of item objects that look like this:
array( "appid" => 440, "contextid" => 2, "amount" => 1, "assetid" => "1627590398" )
If success it will return an object with tradeofferid of the newly created trade offer.
getOffers(options)
getOffer(options)
The first method loads a list of trade offers, and the second loads just a single offer.
Options:
In return you will get an object that Steam Web API returns. The only thing to note is that the wrapper adds a property steamid_other with the SteamID of the trade partner to each CEcon_TradeOffer object in received trades.
declineOffer(options)
acceptOffer(options)
cancelOffer(options)
declineOffer or acceptOffer that was sent to you. cancelOffer that you sent.
Options:
tradeOfferIdis a trade offer Id
In return you will get an object with response from Steam, but don't expect anything meaningful in it.
getOfferToken()
In return you will get the offer token of the bot, extracted from its trade offer URL.
getItems(options)
Options:
tradeIdis the ID of the completed trade you want to get items for, available as atradeidproperty on offers fromgetOffersorgetOffer
In return you will get an array of items acquired in a completed trade.