Chilkat Online Tools

C / Zoom API / Get plan usage

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *v_type;
    int hosts;
    int usage;
    const char *v_Type;
    int Hosts;
    int Usage;
    const char *plan_zoom_roomsType;
    int plan_zoom_roomsHosts;
    int plan_zoom_roomsUsage;
    const char *Free_storage;
    const char *Free_storage_usage;
    const char *Plan_storage;
    const char *Plan_storage_usage;
    const char *Plan_storage_exceed;
    int i;
    int count_i;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttp_Create();

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttp_putAuthToken(http,"<access_token>");

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://api.zoom.us/v2/accounts/:accountId/plans/usage",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttp_getLastStatus(http);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttp_lastHeader(http));
        printf("Failed.\n");
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "plan_base": {
    //     "type": "monthly",
    //     "hosts": 2,
    //     "usage": 1
    //   },
    //   "plan_zoom_rooms": {
    //     "type": "zroom_monthly",
    //     "hosts": 1,
    //     "usage": 0
    //   },
    //   "plan_webinar": [
    //     {
    //       "type": "webinar1000",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_zoom_events": [
    //     {
    //       "type": "zoomevents500_monthly",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_large_meeting": [
    //     {
    //       "type": "large500_monthly",
    //       "hosts": 1,
    //       "usage": 1
    //     }
    //   ],
    //   "plan_recording": {
    //     "free_storage": "3 GB",
    //     "free_storage_usage": "0",
    //     "plan_storage": "0",
    //     "plan_storage_usage": "0",
    //     "plan_storage_exceed": "0"
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    v_Type = CkJsonObject_stringOf(jResp,"plan_base.type");
    Hosts = CkJsonObject_IntOf(jResp,"plan_base.hosts");
    Usage = CkJsonObject_IntOf(jResp,"plan_base.usage");
    plan_zoom_roomsType = CkJsonObject_stringOf(jResp,"plan_zoom_rooms.type");
    plan_zoom_roomsHosts = CkJsonObject_IntOf(jResp,"plan_zoom_rooms.hosts");
    plan_zoom_roomsUsage = CkJsonObject_IntOf(jResp,"plan_zoom_rooms.usage");
    Free_storage = CkJsonObject_stringOf(jResp,"plan_recording.free_storage");
    Free_storage_usage = CkJsonObject_stringOf(jResp,"plan_recording.free_storage_usage");
    Plan_storage = CkJsonObject_stringOf(jResp,"plan_recording.plan_storage");
    Plan_storage_usage = CkJsonObject_stringOf(jResp,"plan_recording.plan_storage_usage");
    Plan_storage_exceed = CkJsonObject_stringOf(jResp,"plan_recording.plan_storage_exceed");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"plan_webinar");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        v_type = CkJsonObject_stringOf(jResp,"plan_webinar[i].type");
        hosts = CkJsonObject_IntOf(jResp,"plan_webinar[i].hosts");
        usage = CkJsonObject_IntOf(jResp,"plan_webinar[i].usage");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"plan_zoom_events");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        v_type = CkJsonObject_stringOf(jResp,"plan_zoom_events[i].type");
        hosts = CkJsonObject_IntOf(jResp,"plan_zoom_events[i].hosts");
        usage = CkJsonObject_IntOf(jResp,"plan_zoom_events[i].usage");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"plan_large_meeting");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        v_type = CkJsonObject_stringOf(jResp,"plan_large_meeting[i].type");
        hosts = CkJsonObject_IntOf(jResp,"plan_large_meeting[i].hosts");
        usage = CkJsonObject_IntOf(jResp,"plan_large_meeting[i].usage");
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/accounts/:accountId/plans/usage

Postman Collection Item JSON

{
  "name": "Get plan usage",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "accounts",
        ":accountId",
        "plans",
        "usage"
      ],
      "variable": [
        {
          "key": "accountId"
        }
      ]
    },
    "description": "Get information on usage of [plans](https://marketplace.zoom.us/docs/api-reference/other-references/plans) of an account. This API supports regular accounts as well as master and sub accounts. To get plan usage of a regular account, use the `account:read:admin` scope and provide “me” as the value of the  `accountId` path parameter.To get plan usage of a master account, provide the keyword \"me\" as the value of the `accountId` path parameter and use the `billing:master` scope. To get plan usage of a sub account, provide the actual account Id of the sub account as the value of the `accountId` path parameter and use the `billing:master` scope. \n\n**Prerequisite**:<br>\nAccount type: master account on a paid Pro, Business or Enterprise plan.<br>\n**Scope:** `billing:master` for master and sub accounts. `account:read:admin` for regular Zoom accounts.<br>\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`"
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200` <br>\nPlan Usage returned.<br>",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "usage"
          ],
          "variable": [
            {
              "key": "accountId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"plan_base\": {\n  \"type\": \"monthly\",\n  \"hosts\": 2,\n  \"usage\": 1\n },\n \"plan_zoom_rooms\": {\n  \"type\": \"zroom_monthly\",\n  \"hosts\": 1,\n  \"usage\": 0\n },\n \"plan_webinar\": [\n  {\n   \"type\": \"webinar1000\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_zoom_events\": [\n  {\n   \"type\": \"zoomevents500_monthly\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_large_meeting\": [\n  {\n   \"type\": \"large500_monthly\",\n   \"hosts\": 1,\n   \"usage\": 1\n  }\n ],\n \"plan_recording\": {\n  \"free_storage\": \"3 GB\",\n  \"free_storage_usage\": \"0\",\n  \"plan_storage\": \"0\",\n  \"plan_storage_usage\": \"0\",\n  \"plan_storage_exceed\": \"0\"\n }\n}"
    },
    {
      "name": "**HTTP Status Code:** `400` <br>\n**Error Code:** `200` <br>\nOnly available for paid account.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/plans/usage",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "plans",
            "usage"
          ],
          "variable": [
            {
              "key": "accountId"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}