title: Etsy API Pagination with PHP
body: <p>So, I'm fairly new to working with APIs, and am just trying to play around with using the Etsy API to display a certain set of listings. </p>
  
  <p>By default, the API returns a set of 25 results, and can do a max of 100 at a time. I'd like to show more than that, so I'm trying to add pagination to my call. Here's what I've got so far:</p>
  
  <pre><code>&lt;?php
  
  //setting API key
  
  define("API_KEY", XXX);
  
  //setting request url
  
  $url = "https://openapi.etsy.com/v2/listings/active?keywords=unicorn,unicorns&amp;includes=Images:1:0&amp;api_key=" . API_KEY;
  
  while (isset($url) &amp;&amp; $url != '') {
  
          $curl = curl_init($url);
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
          $response_body=curl_exec($curl);
          curl_close($curl);
  
          $response = json_decode($response_body);
  
          foreach ($response-&gt;results as $listing) {
                  echo "&lt;li&gt;" . $listing-&gt;title . " ~*~ " . $listing-&gt;price . " " . $listing-&gt;currency_code . " ~*~ " . '&lt;a href="' . $listing-&gt;url . '" target="_blank"&gt;View on Etsy!&lt;/a&gt;' . "&lt;/li&gt;" . "&lt;br&gt;";
          }
  
          $url = $response-&gt;pagination-&gt;next_page;
  }
  
  ?&gt;
  </code></pre>
  
  <p>I thought this would loop through and return the next set of 25 results, but it didn't. Anyone have experience working with this? Is there somewhere I'm getting tripped up?</p>
  
  <p>Thanks!</p>