logo

Steam Trades

Overview

Steam Trades is an application programming interface that serves as a wrapper for official Steam APIs, Steam accounts and introduces error handling. From day one the goal was and is to provide a simple, fully documented and stable application layer between Steam and your application. The API powered by a reliable infrastructure that handles issues, which you would usually have to work out yourself. This core foundation includes but is not limited to account and mobile authentication, error handling, as well as the tracking of items across bot accounts. So instead of dealing with Steam issues, you can focus on your core business.
This document provides the most basic overview to get you familiar with our REST API.

Key Concepts

Inventory

Our API provides an abstraction layer between storage and trade bots, so all your bots inventories are just one big inventory. The inventory is distributed across bots to provide the best availability of items and maximize storage capacity. Think of it as a Steam item cloud that scales indefinitely.

Trades

Steam Trades allows you to request and send items from and to other Steam users. You let us know what you want to do and we will make it happen as fast as steamly possible.

Trade bundling

Remember that there is one big inventory for all bots? Yeah, this sometimes means items in one trade are spread across different bots, which would result in multiple trades and higher error rates. We will arrange all items before sending them, so the user will only get one trade.

Authentication

Steam Trades does not offer any public endpoints. You will need proper credentials for all endpoints.

API tokens provide a simple, yet secure authentication method. The token is transmitted in the Authorization HTTP header, prefixed with the string Token. All requests over plain HTTP will be denied. Always use HTTPS when performing API requests.

HTTP

copy
GET /api/v1/game/ HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
from steamtrades_api import configuration as st_config

st_config.api_key_prefix = {'Authorization': 'Token'}
st_config.api_key = {'Authorization': '<YOUR TOKEN>'}

PHP

copy
<?php
SteamTrades\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Token');
SteamTrades\Configuration::getDefaultConfiguration()->setApiKey('Authorization', '<YOUR TOKEN>');

Inventory

To initiate trades, you will have to know the users' inventory.

Item

A single item in a user's inventory has a unique ID which remains the same even when the item is traded. This differs from Steam where item IDs always change. An item belongs to an ItemCategory.

ItemCategory

Category of items of a particular kind. The general structure remains identical across all categories Typ | Skin (Quality), e.g. M4A1 | Hyper Beast (Field-Tested).

InventoryContext

Filter for items of a given context, e.g. "CS:GO Backpack". Can be used to filter results when performing inventory scans. Again, other than Steam's inventory IDs (which in fact aren't IDs), ours are unique.

Scanning foreign user inventories

Inventory scans are performed in three steps. First, you request an inventory scan using the /item/scan_user_inventory/ endpoint. Then, you repeat this request until it indicates that the scan has completed. Now, the result can be retrieved using the /item/user_inventory/ endpoint.

HTTP

copy
POST /api/v1/item/scan_user_inventory/?trade_url=<TRADE URL>&context_id=1 HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

GET /api/v1/item/user_inventory/?trade_url=<TRADE URL>&context_id=1 HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
from steamtrades_api import TradeApi
import time

api = TradeApi()
force_refresh = False
trade_url = '<TRADE URL>'
context_id = 1  # CS:GO Backpack

# Query scan status and if `force_refresh`, queue new one.
scan_status = None
while not scan_status or not scan_status.completed:
    scan_status = api.item_scan_user_inventory_post(
        trade_url,
        context_id,
        force_refresh=force_refresh if scan_status is None else False
    )
    time.sleep(scan_status.eta)

# Did the scan fail?
if scan_status.failed:
    print('Inventory scan failed (probably private inventory).')
else:
    # Query scan results.
    items = api.item_user_inventory_get(trade_url, context_id)
    from pprint import pprint
    pprint(items)

PHP

copy
<?php
require_once('autoload.php');

$api = new SteamTrades\Api\TradeApi();
$tradeUrl = '<TRADE URL>';
$contextId = 1;  // CS:GO Backpack
$forceReload = false;

// Request inventory and wait for completion.
$result = null;
while ($result === null || !$result->getCompleted()) {
    $result = $api->itemScanUserInventoryPost(
        $tradeUrl,
        $contextId,
        // First query? Force reload, if requested.
        $result === null ? $forceReload : false
    );
    sleep($result->getEta());
}

// Did the scan fail?
if ($result->getFailed()) {
    // Handle failure (probably private inventory)
}
else {
    // Obtain result.
    $result = $api->itemUserInventoryGet($tradeUrl, $contextId);
    print_r($result);
}

Querying your own inventory

To obtain information about your own inventory, the /item/mine/ can be used. Other than with foreign inventories, your own inventory can be retrieved without previously starting a scan, making it pretty straight-forwarded.

HTTP

copy
GET /api/v1/item/mine/ HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
my_items = api.item_mine_get()
from pprint import pprint
pprint(my_items)

PHP

copy
$myItems = $api->itemMineGet();
print_r($myItems);

Trades

Requesting items

Items are requested using the /trade/request_items/ endpoint. In order to obtain the asset IDs sent to this endpoint identifying what items to request, please have a look at how to scan user's inventories.

HTTP

copy
POST /api/v1/trade/request_items/?trade_url=<TRADE URL>&context=1&items=129674693,129612650 HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
# Due to limitations of the Swagger code generator, IDs have to be strings here.
trade = api.trade_request_items_post('<TRADE URL>', 1, ['129674693', '129612650'])
from pprint import pprint
pprint(trade)

PHP

copy
// IDs are strings allow big integers without risk of truncation.
$trade = $api->tradeRequestItemsPost('<TRADE URL>', '1', ['129674693', '129612650']);
print_r($trade);

Sending items

Sending items is similar, but using the /trade/send_items/ endpoint and SteamTrades items IDs from your own inventory instead of Steam asset IDs. This allows us to perform internal arrangement trades without you having to worry about changing asset IDs.

HTTP

copy
POST /api/v1/trade/send_items/?trade_url=<TRADE URL>&items=3741,3779 HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
# Due to limitations of the Swagger code generator, IDs have to be strings here.
trade = api.trade_send_items_post('<TRADE URL>', ['3741', '3779'])
from pprint import pprint
pprint(trade)

PHP

copy
// IDs are strings allow big integers without risk of truncation.
$trade = $api->tradeSendItemsPost('<TRADE URL>', ['3741', '3779']);
print_r($trade);

Polling the status of a trade

After successfully submitting a request for either sending or requesting items using the methods described above, you can now poll for updates on the trade status using the /trade/{id}/ endpoint, submitting the trade ID returned by the trade creation endpoints.

HTTP

copy
GET /api/v1/trade/123/ HTTP/1.0
Host: steamtrad.es
Authorization: Token <YOUR TOKEN>

Python

copy
trade_info = api.trade_id_get(trade_id)
from pprint import pprint
pprint(trade_info)

PHP

copy
$tradeInfo = $api->tradeIdGet($tradeId);
print_r($tradeInfo);