Usage API

The Usage API is a free REST API that provides programmatic access and visibility into activity consumption across products for your account. It is the most important and best tool for helping to monitor and manage usage across the different APIs under your account.

Get usage

public static APIUsage get()

This call retrieves the API usage for current month.

Arguments

None

Returns

This call returns an APIUsage object, and throws an APIException otherwise.

Example

package examples;

import com.objectia.ObjectiaClient;
import com.objectia.api.Usage;
import com.objectia.exceptions.APIException;
import com.objectia.exceptions.ResponseException;
import com.objectia.models.APIUsage;

public class Example {
    public static void main(String[] args) {
        String apiKey = System.getenv("OBJECTIA_APIKEY");

        try {
            ObjectiaClient.init(apiKey);
            APIUsage usage = Usage.get();
            System.out.println("Mail requests: " + usage.getMailRequests());
        } catch (ResponseException e) {
            System.err.println("Response error: " + e.getMessage());
        } catch (APIException e) {
            System.err.println("API error: " + e.getMessage());
        }
    }
}