<p>Your problem is that you only get the market data once, then keep displaying the same values.  Move your call to <code>cryptsy.getMarkets()</code> inside your while loop, like so:</p>

<pre><code>public static void main (String [] args) throws CryptsyException, InterruptedException{

      Cryptsy cryptsy = new Cryptsy();
      cryptsy.setAuthKeys("&lt;authkey&gt;", "&lt;authpass&gt;");

      while(true){
         markets = cryptsy.getMarkets();
         for(Market market : markets) {
            DecimalFormat df = new DecimalFormat("#.########");
            if(market.label.equals("DOGE/BTC"))
               System.out.println(market.label + "   " + df.format(market.last_trade) + "   " + market.current_volume );
         }
         TimeUnit.SECONDS.sleep(5);
      }   
   }
</code></pre>

CC BY-SA 3.0
2014-01-23T21:52:31.187Z
2014-01-23T21:52:31.187Z
Eric Petroelje
<p>I am trying to use the cryptsy's API to get the current price of doge. This is my code.</p>

<pre><code>public class Main {

   static Market [] markets;

   public static void main (String [] args) throws CryptsyException, InterruptedException{

      Cryptsy cryptsy = new Cryptsy();
      cryptsy.setAuthKeys("&lt;authkey&gt;", "&lt;authpass&gt;");


      markets = cryptsy.getMarkets();
      while(true){
         for(Market market : markets) {
            DecimalFormat df = new DecimalFormat("#.########");
            if(market.label.equals("DOGE/BTC"))
               System.out.println(market.label + "   " + df.format(market.last_trade) + "   " + market.current_volume );
         }
      TimeUnit.SECONDS.sleep(5);
      }   
   }
}
</code></pre>

<p>the problem is that the price get updated too rear (30 mins or something) and only if I restart my program. Anyone to know hot to get the current price?</p>

CC BY-SA 3.0
2014-01-19T11:43:39.007Z
This question appears to be off-topic because it is a programming question.
Stéphane Gimenez
CC BY-SA 3.0
2014-01-19T14:08:07.280Z
Agree - ought to be moved to Stack Overflow, where I believe the chances for it to be answered are way higher.
Joe Pineda
<api><cryptsy>
Simple cryptsy market price observer HOW?
user1761818
# Simple cryptsy market price observer HOW?

(Asked by: username_0 on 2014-01-19)

I am trying to use the cryptsy's API to get the current price of doge. This is my code.

```
public class Main {

   static Market [] markets;

   public static void main (String [] args) throws CryptsyException, InterruptedException{

      Cryptsy cryptsy = new Cryptsy();
      cryptsy.setAuthKeys("<authkey>", "<authpass>");

      markets = cryptsy.getMarkets();
      while(true){
         for(Market market : markets) {
            DecimalFormat df = new DecimalFormat("#.########");
            if(market.label.equals("DOGE/BTC"))
               System.out.println(market.label + "   " + df.format(market.last_trade) + "   " + market.current_volume );
         }
      TimeUnit.SECONDS.sleep(5);
      }   
   }
}

```

the problem is that the price get updated too rear (30 mins or something) and only if I restart my program. Anyone to know hot to get the current price?

**Tags:** api, cryptsy

> **Comments:**
> **username_1**: This question appears to be off-topic because it is a programming question.  
> **username_2**: Agree - ought to be moved to Stack Overflow, where I believe the chances for it to be answered are way higher.  

---

## 1 answers

### Answer by username_3 on 2014-01-23. Score: 1

Your problem is that you only get the market data once, then keep displaying the same values. Move your call to `cryptsy.getMarkets()` inside your while loop, like so:

```
public static void main (String [] args) throws CryptsyException, InterruptedException{

      Cryptsy cryptsy = new Cryptsy();
      cryptsy.setAuthKeys("<authkey>", "<authpass>");

      while(true){
         markets = cryptsy.getMarkets();
         for(Market market : markets) {
            DecimalFormat df = new DecimalFormat("#.########");
            if(market.label.equals("DOGE/BTC"))
               System.out.println(market.label + "   " + df.format(market.last_trade) + "   " + market.current_volume );
         }
         TimeUnit.SECONDS.sleep(5);
      }   
   }

```


---

