Java sample code

This sample contains Java example for connecting FRUITS API and JSON response

Sample code for connecting FRUITS API

URL url;
try {
    url = new URL("https://fwallet.net/fruits?requestType=getAccount&account=FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("GET");

    int status = con.getResponseCode();
    if (status == 200) {
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer content = new StringBuffer();
        while ((inputLine = in .readLine()) != null) {
            content.append(inputLine);
        }
        System.out.println(content); in .close();
    }
    con.disconnect();
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

JSON response

{
   "balanceNQT":"4202438479",
   "unconfirmedBalanceNQT":"3702438479",
   "forgedBalanceNQT":"120250000",
   "guaranteedBalanceNQT":"4202438479",
   "accountRS":"FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ",
   "accountRSExtended":"FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ-3KFMRBIORXJQ3USLK6FZ8D4SCRI1K8CA0YB5MAZ7I5QM1TXW1F",
   "assetBalances":[
      {
         "asset":"1722657592827525362",
         "balanceQNT":"820000000"
      },
      {
         "asset":"16174957441139110419",
         "balanceQNT":"450000"
      },
      {
         "asset":"9121771018178014707",
         "balanceQNT":"1000"
      }
   ],
   "unconfirmedAssetBalances":[
      {
         "asset":"1722657592827525362",
         "unconfirmedBalanceQNT":"820000000"
      },
      {
         "asset":"16174957441139110419",
         "unconfirmedBalanceQNT":"100000"
      },
      {
         "asset":"9121771018178014707",
         "unconfirmedBalanceQNT":"1000"
      }
   ],
   "requestProcessingTime":0
}

Last updated