Hub Usage Metrics (GQL)

Here are the GraphQL Platform API queries behind much of the Dashboard tab of the Admin Panel. These queries help to obtain aggregate usage metrics for your Enterprise Hub.

These queries assume you have Environment Admin access to the GraphQL Platform API.

Total number of APIs

This query returns the total number of public and private APIs on the Enterprise Hub. This is the information provided in the Hub section of the Admin Panel Dashboard.

query getHubMetrics($where: MetricsInput!) {
  metrics {
    privateApis(where: $where) {
      totalValue
      __typename
    }
    publicApis(where: $where) {
      totalValue
      __typename
    }
    __typename
  }
}
{
  "where": {
    "fromDate": "2024-03-19T00:00:00.000Z",
    "toDate": "2024-03-26T13:48:27.535Z"
  }
}
{
  "data": {
    "metrics": {
      "privateApis": {
        "totalValue": 253,
        "__typename": "Metric"
      },

      "publicApis": {
        "totalValue": 16,
        "__typename": "Metric"
      },

      "__typename": "Metrics"
    }
  }
}

API metrics

This query returns the information provided in the APIs section of the Admin Panel Dashboard. Specify the current desired date range in the Variables, and the response will include results for the current range and one period prior to that. This helps see usage trends.

query getApiMetrics($where: MetricsInput!) {
  metrics {
    activeApiConsumers(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    totalApiTraffic(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    totalApiErrors(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    totalApiSpikeArrest(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    topApiTraffic(where: $where) {
      api {
        name
        category
        id
        __typename
      }
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    topApiError(where: $where) {
      api {
        name
        category
        id
        __typename
      }
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    topActiveApiConsumers(where: $where) {
      consumer {
        id
        name
        slugifiedName
        type
        parents {
          id
          type
          __typename
        }
        __typename
      }
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    topPopularApis(where: $where) {
      api {
        name
        category
        id
        __typename
      }
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    __typename
  }
}
{
  "where": {
    "fromDate": 1710658800,
    "toDate": 1711436399,
    "excludeProtected": true
  }
}

Governance metrics

This query returns the total number of users, teams, API subscribers, organizations, organization users, API providers, and environment admins on the Enterprise Hub. This is the information provided in the Governance section of the Admin Panel Dashboard. Specify the current desired date range in the Variables, and the response will include results for the current range and one period prior to that. This helps see usage trends.

query getGovernanceMetrics($where: MetricsInput!) {
  metrics {
    users(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    teams(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    subscribers(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    organizations(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    organizationUsers(where: $where) {
      totalValue
      __typename
    }
    providers(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    admins {
      totalValue
      __typename
    }
    __typename
  }
}
{
  "where": {
    "fromDate": 1710806400,
    "toDate": 1711460907,
    "excludeProtected": true
  }
}
{
  "data": {
    "metrics": {
      "users": {
        "totalValue": 150,
        "currentPeriodValue": 1,
        "previousPeriodValue": 0,
        "__typename": "Metric"
      },

      "teams": {
        "totalValue": 45,
        "currentPeriodValue": 0,
        "previousPeriodValue": 0,
        "__typename": "Metric"
      },

      "subscribers": {
        "totalValue": 117,
        "currentPeriodValue": 0,
        "previousPeriodValue": 0,
        "__typename": "Metric"
      },

      "organizations": {
        "totalValue": 28,
        "currentPeriodValue": 0,
        "previousPeriodValue": 0,
        "__typename": "Metric"
      },

      "organizationUsers": {
        "totalValue": 84,
        "__typename": "Metric"
      },

      "providers": {
        "totalValue": 58,
        "currentPeriodValue": 0,
        "previousPeriodValue": 0,
        "__typename": "Metric"
      },

      "admins": {
        "totalValue": 45,
        "__typename": "MetricBase"
      },

      "__typename": "Metrics"
    }
  }
}

Billing metrics

Assuming your enterprise uses Billing, this query returns the gross revenue, net revenue, and number of successful payments made on the Enterprise Hub. This is the information provided in the Billing section of the Admin Panel Dashboard. Specify the current desired date range in the Variables, and the response will include results for the current range and one period prior to that. This helps see usage trends.

query getBillingMetrics($where: MetricsInput!) {
  metrics {
    grossValue(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    netValue(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    successfulPayment(where: $where) {
      totalValue
      currentPeriodValue
      previousPeriodValue
      __typename
    }
    __typename
  }
}
{
  "where": {
    "fromDate": 1710658800,
    "toDate": 1711436399,
    "excludeProtected": true
  }
}