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 func get() -> APIUsage?

This call retrieves the API usage for current month.

Arguments

None

Returns

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

Example

import Foundation
import Objectia

extension String: Error {}

do {
    guard let apiKey = ProcessInfo.processInfo.environment["OBJECTIA_APIKEY"] else {
        throw "API key not set"
    }
    try ObjectiaClient.initialize(apiKey: apiKey) 
    let usage = try Usage.get()
    print("Mail requests:", usage!.mailRequests)
} catch let err as ObjectiaError {
    print("Request failed:", err) 
} catch {
    print(error) 
}