I'm not sure if I'm approaching this right. I run a trading card game website and signed up with eBay's Partner Network so I could link people to eBay to buy individual cards. Right now I'm able to load a link for each card that says something like "Buy [card name] on eBay" using their standard "Link Generator," but I'd also like to display the average price for the card so people know how much it is before they click the link. Something like "Buy [card name] for $9.99 + 2.99 shipping on eBay!"
I figured I would need to use eBay Partner Network's API to retrieve a listing of available auctions to access the price information, and so I signed up for their developer program. I've been able to get a listing of current auctions using the code below, but I can't figure out how to just simply display an average price or going for price for all current auctions. Right now it displays the prices for every auction, but I've seen other websites that show you what the cost + shipping is for a specific card. I'm not sure if this is even the way to approach this - I've never dealt with any of this before and their documentation isn't very beginner-friendly. ^_^;;
<script>
function _cb_findItemsByKeywords(root)
{
var items = root.findItemsByKeywordsResponse[0].searchResult[0].item || [];
var html = [];
html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');
for (var i = 0; i < items.length; ++i)
{
var item = items[i];
var title = item.title;
var pic = item.galleryURL;
var viewitem = item.viewItemURL;
var selling = item.sellingStatus[0].currentPrice[0]['__value__']
if (null != title && null != viewitem)
{
html.push('<tr>' +
'<td><a href="' + viewitem + '" target="_blank">' + title + '</a></td>' + '<td>' + selling + '</td></tr>');
}
}
html.push('</tbody></table>');
document.getElementById("results").innerHTML = html.join("");
}
</script>