BI metrics analytics API to understand adoption

We are looking to add an internal tool application to monitor the adoption of our APIs. From looking at the APIs available for use from Edge services here:

https://docs.apigee.com/analytics-services/content/use-analytics-api-measure-api-program-performance

The KPI metrics that we are looking for is as below:

  1. Number of developers who signed up for an API key in the last month who have never made an API call
  2. Number of first time, unique visitors on the PDC in the last 30 days
  3. Number of first time, unique visitors on the test environment in the last 30 days
  4. Breakdown of API calls by API products

The only to get the metric 1 above seems like to get all the developers registered by environment and then iterate each of their app to understand the app level statistics. Is there a direct API to query each developer's activity? or engagement and get developer's app statistics? This is just easier to integration into tools like Power BI.

0 3 348
3 REPLIES 3

About metric 1, I'm not sure. you need to be careful in defining exactly what you are attempting to track or measure.

If you want the keys that are new over the past 30 days, and have never been used for an API call, that is one thing. For this you start by querying:

curl -i -n $mgmtserver/v1/o/$ORG/apps?expand=true

The result is a set of records like this:

{
    "accessType" : "",
    "apiProducts" : [ ],
    "appFamily" : "default",
    "appId" : "3e2c802e-47ce-4905-88cf-8a9e098938be",
    "attributes" : [ {
      "name" : "DisplayName",
      "value" : "My Mobile App"
    }, {
      "name" : "Notes",
      "value" : ""
    } ],
    "callbackUrl" : "",
    "createdAt" : 1515552379482,
    "createdBy" : "dchiesa@google.com",
    "credentials" : [ {
      "apiProducts" : [ {
        "apiproduct" : "Hotels1",
        "status" : "approved"
      } ],
      "attributes" : [ ],
      "consumerKey" : "VktGArEHIr1w5aLDpKp482BWoxDEN1hh",
      "consumerSecret" : "zHwyBHLuPx07xPne",
      "expiresAt" : -1,
      "issuedAt" : 1515552379556,
      "scopes" : [ ],
      "status" : "approved"
    } ],
    "developerId" : "EUaskGb61YiwTBTW",
    "lastModifiedAt" : 1515965620431,
    "lastModifiedBy" : "gnanasekaran@google.com",
    "name" : "HotelsApp1",
    "scopes" : [ ],
    "status" : "approved"
  } 

Then, filter that list to include only those with credentials, that have an issuedAt date within the past 30 days. Then, query /stats/client_id ,

curl -n -i 'https://api.enterprise.apigee.com/v1/o/$ORG/e/$ENV/stats/client_id?select=sum(message_count)&timeRange=12/31/2017%2023:59~01/31/2018%2023:59'

(remember that client_id is a synonym for "API Key") You will get a result like this:

{
  "environments" : [ {
    "dimensions" : [ {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ "395123.0" ]
      } ],
      "name" : "(not set)"
    }, {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ "266177.0" ]
      } ],
      "name" : "VktGArEHIr1w5aLDpKp482BWoxDEN1hh"
    }, {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ "47824.0" ]
      } ],
      "name" : "lQQxMsPzoH3DG2OWtOYz0JdJZG2w0pF2"
    }, {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ "202505.0" ]
      } ],
      "name" : "KFnJ5bjGI4RNoOQh2Pk7VqZKY0ik4WpM"
    } ],
    "name" : "prod"
  } ]
}

..an then cross those two lists. Any key created in the last 30 days, and not appearing in the stats response, is "an unused key that was created in the past month."

Keep in mind that there is not a 1:1 mapping between app and key. An App can have zero, 1, or more keys, and if the latter, there may be overlapping lifetimes. Also the app createdAt date is not the same as the key issuedAt date. An App might be created in October, and have a key that was issued in January .

If you want the developers that own such keys, just select the developerId of such keys, that satisfy the above. That gives you "developers who have created an unused key that was created in the past month."

If you want the developers that have ONLY keys that are new and have never been used, that's something different. You would need to combine the above with a filter checking all the other keys of each developer, and excluding from the list of developers those devs who have any active keys.

reference:

https://docs.apigee.com/management/apis/get/organizations/%7Borg_name%7D/environments/%7Benv_name%7D...

Thanks for clarifying @Dino

Thanks for clarifying @Dino