How To Use Rainforest API With WordPress

Rainforest API is an alternative to the Amazon Product API provided to Amazon Associates. If you are thinking of building shopping comparison sites with Amazon links and you don’t have an API key, or if you want to build a lot of pages very quickly without limitation, using Rainforest API is the answer. If you are serious about earning money as an Amazon Affiliate and want to make thousands of pages, do yourself a favor and start the project off right. Amazon’s API limit is tied to your revenue and number of calls. The last thing you need is Amazon throttling your site and limiting your revenue. Consider building using the Rainforest API.

Many companies choose to run WordPress no matter what the project. Creating shopping comparison engines or top product lists are not the first thing most people think of when they think of WordPress the CMS. However, when you look at WooCommerce and other highly functional plugins, you can see why companies are insisting WordPress be used in all applications even if its, not the easiest integration. Rainforest API has excellent documentation, but their documentation begins with the call and ends with the output. The guide is for the WordPress User using Chrome, Safari, Firefox, or Brave.

How To:

This “How To” guide will walk you through creating API calls and displaying data on a WordPress page. By the end of the guide you will have a page displaying the Top 10 products for the category “Musical Instruments”. Once you have completed this guide you will be comfortable working with the API to output data to Wordress pages.

What You Need:

  1. Domain Name
  2. Cloud Instance With WordPress Installed (Vultr Is Great).
  3. Free Account From Rainforest API.
  4. Free Json-Content-Importer Plugin for WordPress
  5. Code and Instructions Provided Below

Getting Started:

  1. Sign into WordPress as Admin.
  2. Click on Plugins, Then Add New Plugin.
  3. Search for Json Content Importer, Install and Activate.
  4. If you are using a caching plugin make sure it is setup to automatically detect changes or make sure you clear your cache when testing.
  5. Click on Pages then “Add New“, give your page the title Top 10 Musical Instrument Best Sellers List.
  6. Click on Publish.
  7. View your page, it should be empy with no errors showing.
  8. Leave the tab with your WordPress site open. and open two additional tabs, on one go to and the other go to

Getting Your API Link:

  1. At click on “Log in” and enter the credentials you used when you signed up. If you haven’t signed up, do so now and login.

API Playground

2. Click on API Playground on the left side of the screen.

3. Go to in your other open browser tab and navigate to the Best Sellers

List of categories on Amazon

4. Click on Musical Instruments on the left hand side.

URL BAR and Amazon Header

5. Copy the URL from the Musical Instruments Best Sellers page and navigate back to the Rainforest API tab thats open in your browser.

You should still be in the API Playground (if not click on it).

drop down list of products and best sellers

7. The first Dropdown box in API Playground says Type and has Product set by default. Select BestSellers from the drop down list.Type and URL Boxes With Arrows Pointing

8. In the URL box paste the link from the Musical Instrument Best Seller list we copied from

Arrow pointing to boxes contianing affiliate ID and JSON output type

9. The rest of the boxes on this page should be blank except for output which should be JSON and Associate ID which is your Amazon Associate ID. You can find this ID by logging in to your Amazon Associates account, or leave blank if you dont have one yet.

Arrow pointing to SEND API REQUEST button

10. Press the Send API Request button.

JSON return form api with arrows

11. Scroll up to the top of the page. You should have the output from the API request displaying on the right hand side. You will see in the output something called bestsellers, this array contains all the information needed. Click on this array and click on one of the numbers to display the single product information.

*Note that inside bestsellers there is another array called price. The code accesses the price array to demonstrate this with the JSON Content Importer shortcode for WordPress.

Code sample button

12. In the Rainforest API dashboard click on “Code Sample“.

Code Samples. Php Python Curl Node.JS

13. Rainforest API offers Code Samples in URL, Curl, Node.JS, Python and PHP. For our purposes, select URL and click the copy button to copy the URL to clipboard. Paste this URL somewhere safe, the URL should begin with – NOT the Amazon link from earlier.

Configuring WordPress For Rainforest API:

14. Go back to the browser tab that has your WordPress session open. Open the page you created earlier called Top 10 Musical Instrument Best Seller List.

15. Copy the code between the leading /* and ending */ comment tags:

/* <div style="overflow-x:auto;"><table class="tenstyletable"><tr><td><hr></td></tr><tr><td><b><center>. </b><a href="" rel="nofollow"></a></center></td></tr><tr><td><center><a href="" rel="nofollow"><img src=""></a></center></td></tr><tr><td><center><b>Rating: </b></center></td></tr><tr><td><center><a href="" rel="nofollow"><b></b></td></tr><tr><td><center><img src=""></center></a></b></center></td></tr><tr><td><hr></td></tr></table></div> */

16. Replace the URL after [jsoncontentimporter url=” with the URL you copied from Rainforest API when we sent the request for the Top 10 Musical Instrument Best Seller List. At this point the code should start displaying products if you preview the post. Click Here to see the finished example.

As an alternative, you can simply replace the XXXXXXXX’s in the above code with your API key.

17. The product list will likely look malformed, but the data should show up. If you look at the code, class=”tenstyletable” is defined by the table tag. We need to add CSS to Worpress to style the table.

Customize WordPress Red Arrow Pointing

additional css button red arrow pointing wordpress

18. On your Top 10 Musical Instruments page, click customize on the WordPress Admin bar, then click on Additional CSS, and paste the following code:

table.tenstyletable td {
	border-collapse: collapse;
	display: table-cell;
  vertical-align: middle;

19. Your table should now be showing the Top 10 list. If your formatting is off simply adjust the CSS. Click Here to see an example page.

This guide provides the logic to build out more complicated pages using the Rainforest API and WordPress. With a few minor changes to the boilerplate code above, you can display other information the feed provides or change the way the JSON output is handled. If you want to increase the the number of products displayed for example, simply change the numbers in {subloop-array:bestsellers:10} and {subloop:bestsellers.price:10} – instead of 10 use a another number.

For more advanced configurations be sure to read the JSON-content-importer documents.