title: Amazon Spot Price History - Java Code
body: <p>It should be possible to get the AWS Spot Price history for the past 90 days. When using the Java SDK it's possible to create a query to get some of the history, but because this list is so long they split it up. Using a token you should be able to get the next part of the list, en this until you have received the whole list.</p>
  
  <p>The problem is that using the given token I was not yet able to retrieve more then the first part of the list. While searching the internet it became clear that my understanding of this token is right.</p>
  
  <pre><code>    // Create the AmazonEC2Client object so we can call various APIs.
      AmazonEC2 ec2 = new AmazonEC2Client(credentials);
  
      // Get the spot price history
      DescribeSpotPriceHistoryResult result = ec2.describeSpotPriceHistory();
  
      // Print first part of list
      for (int i = 0; i &lt; result.getSpotPriceHistory().size(); i++) {
          System.out.println(result.getSpotPriceHistory().get(i));
      }
  
      result = result.withNextToken(result.getNextToken());
  
      // Print second part of list
      for (int i = 0; i &lt; result.getSpotPriceHistory().size(); i++) {
              System.out.println(result.getSpotPriceHistory().get(i));
      }
  </code></pre>
  
  <p>The "nextToken" of the result is not changing. Any ideas what I'm doing wrong? Is there a bug in the SDK? I installed it via Eclipse.</p>
  
  <p>Thanks in advance!</p>