Is it possible to query steam with many items and steam response only one json with all prices requested?
No, it's not possible to query Steam with many items which result in a single response with all the data, however it's possible to use cURL's multiget to send multiple requests which each hit the Steam API returning multiple response in a single cURL call.
Example of a curl multi exec:
function curl_get_contents($data) {
$curly = array();
$mh = curl_multi_init();
foreach ($data as $urlArray) {
$curly[$urlArray['name']] = curl_init();
curl_setopt($curly[$urlArray['name']], CURLOPT_URL, $urlArray['url']);
curl_setopt($curly[$urlArray['name']], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curly[$urlArray['name']], CURLOPT_HEADER, false);
curl_setopt($curly[$urlArray['name']], CURLOPT_RETURNTRANSFER, true);
curl_multi_add_handle($mh, $curly[$urlArray['name']]);
}
$running = null;
do {
curl_multi_exec($mh, $running);
} while ($running > 0);
foreach ($curly as $id => $c) {
curl_multi_remove_handle($mh, $c);
}
curl_multi_close($mh);
}
I wrote a function much like this one (removed the additional code because I don't want you to just copy/pasta - learn instead) to take an array of arrays where each inner array contains a name and a URL, and returns an array of data accordingly - for example:
$curlyUrls = array(
array(
'name' => 'Item1 Response',
'url' => 'http://steamcommunity.com/market/priceoverview/?country=ZA¤cy=3&appid=730&market_hash_name=Item1'
),
array(
'name' => 'Item2 Response',
'url' => 'http://steamcommunity.com/market/priceoverview/?country=ZA¤cy=3&appid=730&market_hash_name=Item2'
)
);
$curlyItemResponse = curl_get_contents($curlyUrls);
This method is definitely not recommended for 100+ items. I use this for no more than 10 calls - hitting the Steam API too frequently will likely cause some sort of throttling toward your connection not to mentioned, if this is called too frequently, your 100K daily API threshold will be used up pretty fast.
There are a few workarounds to this, but the best approach I can recommend is storing a list of your known items in a database and creating a cronjob to occasionally update the prices of each item while avoiding mass API calls - that way you have a cached price to each item.