Monitor Your ScraperAPI Account Information in Java

Learn how to monitor your ScraperAPI usage programmatically using the /account endpoint in Java. Get real-time concurrency and updated request stats in JSON format.

If you would like to monitor your account usage and limits programmatically (how many concurrent requests you’re using, how many requests you’ve made, etc.) you may use the /account endpoint, which returns JSON.

Note: the requestCount and failedRequestCount numbers only refresh once every 15 seconds, while the concurrentRequests number is available in real-time.

  • API REQUEST

try {

String apiKey = "APIKEY";
String url = "http://api.scraperapi.com/account?api_key=" + apiKey;
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
int responseCode = conection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}

} catch (Exception ex) {
ex.printStackTrace();
}

Last updated

Was this helpful?