ethgasstation에서 api key를 먼저 받아야함

 

public final static String GASPRICE_API_V3_HTTP_URL="https://ethgasstation.info/api/ethgasAPI.json?api-key=your api key";

 

public static String getGasPrice(int opt, Logger logger)
{
String gasPrice = "337";
Communicator comm = new Communicator();
String response = "";
try {
response = comm.getHttpJsonFromURL2(DefinedConstant.GASPRICE_API_V3_HTTP_URL, logger);
//logger.info(response);
JSONObject jObject = new JSONObject(response);
String temp = "";
if (opt==3)
temp = String.valueOf(jObject.getDouble("fastest"));
else if (opt==2)
temp = String.valueOf(jObject.getDouble("fast"));
else if (opt==1)
temp = String.valueOf(jObject.getDouble("average"));
gasPrice = String.valueOf((int)Double.parseDouble(temp)/10);
}catch (Exception e) {
     logger.error(UtilClass.exceptionToString(e));
    }
return gasPrice;
}

AND