2 <title>API Documentation</title>
5 #result {background:lightgrey;}
6 #selector a {margin-right:10px;}
7 .required {font-weight:bold;}
8 .helpmsg {background:yellow;}
9 .docHidden {display:none;}
10 h2.entity {cursor:pointer}
15 var head= document.getElementsByTagName('head')[0];
16 var script= document.createElement('script');
17 script.type= 'text/javascript';
18 script.src= CRM.config.resourceBase + 'js/packages/jquery/jquery.js';
19 head.appendChild(script);
21 restURL = '{crmURL p="civicrm/api/json"}';
22 if (restURL.indexOf('?') == -1 )
23 restURL = restURL + '?';
25 restURL = restURL + '&';
27 if (typeof $ == "undefined") {
31 function APIDoc(entity){
32 $detail=$('#detail_'+entity);
33 window.location.hash = entity;
34 if ($detail.length == 1) {
35 $detail.toggleClass('docHidden');
37 } // else fetch the field list
38 return function(entity){
39 CRM.api (entity,'getFields',{version : 3}
40 ,{ success:function (data){
41 var h="<table id=detail_"+entity+"><tr><th>Attribute</th><th>Name</th><th>type</th></tr>";
43 $.each(data.values, function(key, value) {
44 if (typeof value.type != 'undefined') {
45 var types={1:"integer",2:"string",4:"date",12:"date time",16:"boolean",32:"blob"}
47 if (type in types) type=types[value.type];
49 if(typeof value.title == 'undefined') {
52 if (typeof value.label != 'undefined') {
53 value.title = value.label + " <i>"+value.extends+"::"+value.groupTitle+"</i>";
54 type = value.data_type;
56 h=h+"<tr><td>"+key+"</td><td>"+value.title+"</td><td>"+type+"</td></td>";
59 $("#"+entity).after(h);
62 }(entity);//closure so entity is available into success.
67 $('h2.entity').click ( function(){APIDoc($(this).attr('id'))} );
68 entity=window.location.hash;
69 if (entity.substring(0, 1) === '#') {
71 if ($entity.length == 1) {
79 You can see the list of parameters for each entity by clicking on its name.<br>
80 You can <a href='{crmURL p="civicrm/api/explorer"}'>explore and try</a> the api directly on your install.
82 {crmAPI entity="Entity" action="get" var="entities" version=3}
83 {foreach from=$entities.values item=entity}
84 <h2 id="{$entity}" class="entity">{$entity}</option>