How to view your API usage count

Syntax

  • http://acapi.kgvp.org//2014-01/Usage/{Registration}{.xml or .json} - returns the usage by object for the registration, followed by an array of instrument usage.
    (i.e. http://acapi.kgvp.org//2014-01/Usage/.json)
  • GET or POST both the 'Start' and 'End' parameter will filter the Instrument usage list to the date range parameters.
    The query is based on the dbo.Results table, so if the results are removed from the table, the query will not be accurate.

Remarks

The following are the API categories:

  • Form List: Count (xx)
  • Assessment: Count (xx)
  • Battery List: Count (xx)
  • Participant: Count (xx)
  • Result: Count (xx)
  • StatelessParticipant: Count (xx)
  • Usage: Count (xx)
  • Calibration List: Count (xx)

API Home

Try it!

Sample code for http://acapi.kgvp.org//2014-01/Usage

  • Javascript
  • C#
  • JSON Formatted Response
  • XML Formatted Response
<script langauge="javascript" src="jquery-1.7.1.min.js"></script>
<script language="javascript" src="crypto.js"></script>
<script type='text/javascript' version='1.3'>

var Server = http://acapi.kgvp.org/;
var RegistrationOID = "31839849-ECE0-4F5E-BEAE-3D655ED65E31";   // Sample registration -- replace with your RegistrationID

function displayUsage() {
    $.ajax({
        url: Server + RegistrationOID + ".json",
        cache: false,
        type: "POST",
        data: "",
        dataType: "json",
	
        beforeSend: function(xhr) {
            var bytes = Crypto.charenc.Binary.stringToBytes(RegistrationOID + ":" + document.getElementById("txtToken").value;);
            var base64 = Crypto.util.bytesToBase64(bytes);
            xhr.setRequestHeader("Authorization", "Basic " + base64);
        },
	
        success: function(data) {
            var container = document.getElementById("Content");
            for (var k = container.childNodes.length - 1 ; k > -1; k--) {
                container.removeChild(container.childNodes[k])
            }
            var _header = document.createElement("div");
            _header.appendChild(document.createTextNode("Below are the API's I have used."));
            container.appendChild(_header);

            for (var i = 0; i < data.Review.length; i++) {
                var _div = document.createElement("div");
                _div.appendChild(document.createTextNode(data.Review[i].API + ": Count (" + data.Review[i].Count + ")"));
                container.appendChild(_div);
            }
        },
	
        error: function(jqXHR, textStatus, errorThrown) {
            document.write(jqXHR.responseText + ':' + textStatus + ':' + errorThrown);
        }
    })
}
                                
Based on twillio example to call RESTful services. (http://www.twilio.com/docs/api/rest)
using System;
using System.Collections;
using System.Configuration;
using System.IO;
using System.Net;
using System.Web;
using System.Text;
using System.Text.RegularExpressions;

public class TestHarness
{
    static void Main(string[] args)
    {
        string REGISTRATIONID ="31839849-ECE0-4F5E-BEAE-3D655ED65E31";  // Sample registration -- replace with your RegistrationID
        string TOKEN ="F3738486-5A7D-41EF-8044-DCBAF800E2D4";           // Sample token -- replace with your TokenOID
        string API_URL =  "http://acapi.kgvp.org//2014-01/Usage/" + REGISTRATIONID + ".xml";

        string authstring = Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", REGISTRATIONID, TOKEN)));
        ServicePointManager.Expect100Continue = false;     
        Byte[] postbytes = Encoding.ASCII.GetBytes(string.Empty);
        WebClient client = new WebClient();
        client.Headers.Add("Authorization", String.Format("Basic {0}", authstring)); 
        client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");    
        byte[] resp = client.UploadData(API_URL, "post", postbytes);
        Console.WriteLine(Encoding.ASCII.GetString(resp));
    }
}
                                
// Requesting the number of times each API was called for a given RegistrationID
Request:http://acapi.kgvp.org//2014-01/Usage/{RegistrationID}.json

Response:
{
    "Review": [
        {
            "API": "Form List",
            "Count": "3"
        },
        {
            "API": "Calibration List",
            "Count": "4"
        },
        {
            "API": "Assessment",
            "Count": "2"
        },
        {
            "API": "Participant",
            "Count": "9"
        },
        {
            "API": "Result",
            "Count": "3"
        },
        {
            "API": "Usage",
            "Count": "2"
        }
    ],
	"Instruments": [
	{
		"Name": "PROMIS SF Ped v1.0 - Impacto de la fuerza 4a",
		"AdministeredCount": "5"
	},
	{
		"Name": "PROMIS SF Ped v1.0 - Impacto de la fuerza 8a",
		"AdministeredCount": "5"
	},
	{
		"Name": "PROMIS Bank v2.0 - Ability to Participate Social",
		"AdministeredCount": "2"
	}
	]
}
                                
// Requesting the number of times each API was called for a given RegistrationID
Request:http://acapi.kgvp.org//2014-01/Usage/{RegistrationID}.xml

Response:
<?xml version="1.0" encoding="utf-16"?>
<Review>
    <Type API="Form List" Count="3" />
    <Type API="Calibration List" Count="4" />
    <Type API="Assessment" Count="2" />
    <Type API="Participant" Count="9" />
    <Type API="Result" Count="3" />
    <Type API="Usage" Count="3" />
    <Instrument Name="PROMIS SF Ped v1.0 - Impacto de la fuerza 4a" AdministeredCount="5" />
    <Instrument Name="PROMIS SF Ped v1.0 - Impacto de la fuerza 8a" AdministeredCount="5" />
    <Instrument Name="PROMIS Bank v2.0 - Ability to Participate Social" AdministeredCount="2" />
</Review>