Using the LinkShare Merchandiser Web Service

Linkshare Web Services

Linkshare Web Services

Building a product site using the LinkShare Merchandiser Web Service is one of the easiest and most straight-forward tasks you can do. If you’re just getting started with datafeeds and product-based sites, you may want to start here.

If you don’t have an account, you first need to signup with LinkShare. Then login, and click on Web Services under Links. Next, generate or update your token. You’ll need this when making requests.

When I first generated my token, the services were not working for me. After contacting support (which was easy to do), they promptly replied:

Please be note that the feed token MAY take up to 24 hours to fully activate from the time it was initially generated/reset.

Linkshare Web Services Token

Linkshare Web Services Token

However, 30 minutes after being generated, the token was active.

Building the query URL is fairly straight-forward. At its simplest, you pass your token and a keyword:

http://productsearch.linksynergy.com/productsearch?token=[your token here]&keyword=backpack

Refer to the Merchandiser Query API page for documentation on the other parameters you may use, such as category, merchant, and sorting.

Putting it all together:

$cURL = 'http://productsearch.linksynergy.com/productsearch?token=[your token here]&keyword=backpack';
$xml = simplexml_load_file($cURL);

for ($i = 0; $i < count($xml->item); $i++) {
	$oProduct = $xml->item[$i];
	<div class="post">
		<h2 class="title"><a href="<?= $oProduct->linkurl ?>" target="_blank" style="text-decoration:none"><?= $oProduct->productname ?></a></h2>
		<div class="entry">
			<p><a href="<?= $oProduct->linkurl ?>" target="_blank"><img src="<?= $oProduct->imageurl ?>" alt="<?= $oProduct->productname ?>" title="<?= $oProduct->productname ?>" style="max-height:100px; max-width:100px; float:left" onerror="ImgError(this)" /></a><?= $oProduct->description->short ?></p>
			<br style="clear:all" />
		<div class="meta">
			<p class="byline"><a href="<?= $oProduct->linkurl ?>">$<?= number_format($oProduct->price, 2) ?></a></p>
			<p class="links"><a href="<?= $oProduct->linkurl ?>" class="more">Get More Info</a> <b>|</b> From <a href="<?= $oProduct->linkurl ?>" class="comments"><?= $oProduct->merchantname ?></a></p>

Refer to the 3rd step in my Building a Datafeed Site series for an explanation of the ImgError JavaScript event.

This PHP code is meant to be dropped into a static WordPress template, many of which can be downloaded from free CSS templates.

If you wanted to improve performance, you could save the Merchandiser results to MySQL for local caching.

To see a site built on the LinkShare Merchandiser API, check out this site on Transcend SD Cards.

May 11, 2011 Update
LinkShare has updated the URLs for their APIs. The code here has been reflected with the new URLs.

Share this Story:
  • facebook
  • twitter
  • gplus


  1. Garrett
    2971 days ago

    Nice write-up. As always, the code samples are a huge help for wrapping your mind around how feeds function. FYI, I’m currently seeing feed errors on your SD site (not sure if it’s your side or LS).


    • Eric Nagel
      2971 days ago

      Hahaha – of course, the service is down now 🙂

      Maybe my next post should be about using memcache to cache results for when the provider’s API goes down 🙂

      • Garrett
        2971 days ago

        I’d by interested in that one…seems like hitting APIs in realtime (in my limited experience) is a quick/easy way to get rolling, but probably not a great long-term solution if your site gets good traction.

  2. Trackback: Data Feeds – Using the LinkShare Merchandiser Web Service (Eric Nagel Blog) | LinkShare UK Blog

  3. Trackback: Affiliate Marketing Data Feeds – Using the LinkShare Merchandiser Web Service (Erc Nagel Blog) | LinkShare Blog

  4. Sarita
    2279 days ago

    Hi I am facing the following error on running the file:

    Warning: simplexml_load_file() [function.simplexml-load-file]: http%3A%2F%2Fmyprojectdemonstration.com%2Fdevelopment%2Fprojecttest%2Fcashverseur%2FAPI%2Flinkshare%2Findex.php%3Ftoken%3D594978f1ee8529987d5d516816e57358fa79ca6c3206108fdfada906a9eac5e2:2: parser error : Extra content at the end of the document in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50

    Warning: simplexml_load_file() [function.simplexml-load-file]: Warning: simplexml_load_file() [f in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50

    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/myprojec/public_html/development/projecttest/cashverseur/API/linkshare/index.php on line 50
    There are no available products at this time.

    I have put the url=”http://myprojectdemonstration.com/development/projecttest/cashverseur/API/linkshare/”

    $token = “594978f1ee8529987d5d516816e57358fa79ca6c3206108fdfada906a9eac5e2”;

    Please share the code if there is some php support error.I am runnig PHP 5.2.1 on my server.


  5. Sarita
    2278 days ago

    No, I am not.I just want to get all products not any specific but i started with this value.Could you please help me how to get all products?I have only account and also don’t have much information about this.But i just want to get all products without any criteria.
    Many thanks!

    • Eric Nagel
      2278 days ago

      Review the documentation to see if this is available. You may be better off with their FTP service, and just download the feeds

  6. Sarita
    2269 days ago

    Can’t i get any product feed if I’m not approved by any merchant program?

    • Eric Nagel
      2268 days ago

      No. You must be approved to a program before you can get the feed.

  7. Sarita
    2268 days ago

    Thanks for the reply Eric.

  8. Sarita
    2268 days ago

    Thanks Eric.Finally i got products.Can you help me with clickbank API to get products?

  9. Ritesh
    2139 days ago

    i am new in feed api development.
    i have one problem in linkedshare product full merchandiser file in php how to i can auto download file from my ftp.
    i use ft_get but its only download 10 file.

    than i have one more query how to easy way to in parse this .xml.gz file to table please guide me.


    • Eric Nagel
      2107 days ago


      I seem to recall something goofy about how Linkshare handles FTP files. Like the files don’t actually exist, but if you request them, it’ll magically appear and be sent to you? It’s unrelated to the API, so I don’t know much more about it.

      Use the API to determine your merchant relationships, then request the file (even if it’s not there) and you may get it.

  10. david E
    2112 days ago

    would you know how to query the linkshare Merchandiser Query tool by isbn. I cant find information on that anywhere

    • Eric Nagel
      2107 days ago


      I doubt you can. Maybe use another API to go from ISBN -> book title, then search Linkshare for the book title?

  11. Muhammad Junaid
    1887 days ago


    Please can you help me to get Sales from the Linkshare? I could not find any sufficient data about the API. Thanks in advance.

  12. rajp
    1851 days ago

    My code works perfect on my local machine but fails on the hosting site.Did you overcome anything like this issue with hosting.is it something to do with the simplexml_load_file is not enabled on hosting

    • Eric Nagel
      1851 days ago

      It could be just about anything – what’s the error message you’re receiving?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.