source: trunk/grails-app/views/api/index.gsp @ 2188

Last change on this file since 2188 was 2188, checked in by work@…, 9 years ago
  • added / improved api documentation
  • added getAssaysForStudy api method
  • simplified and centralized simplication method for flattening domain data
File size: 14.4 KB
Line 
1<html>
2<head>
3    <meta name="layout" content="main"/>
4    <style type="text/css">
5        .api {
6            margin-top: -40px;
7        }
8
9        .api .header {
10            color: #ffda27;
11            font-size: 24px;
12            height: 40px;
13        }
14
15        .api h1 {
16            background-color: #006DBA;
17            padding-left: 10px;
18            margin-top: 40px;
19            height: 30px;
20            padding-top: 10px;
21            color: #fff;
22            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.68);
23        }
24
25        .api h2 {
26            font-size: 12px;
27            background-color: #d7e6f1;
28            padding-left: 10px;
29            margin-top: 10px;
30            height: 20px;
31            padding-top: 5px;
32            font-weight: bold;
33            color: #006DBA;
34            text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
35        }
36
37        .api h3 {
38            font-size: 12px;
39            font-weight: bold;
40            color: #ee7624;
41            text-shadow: 0 1px 1px rgba(0, 0, 0, 0.28);
42        }
43       
44        .api li {
45            margin-left: 30px;
46        }
47    </style>
48</head>
49<body>
50<div class="api">
51<h1 class="header">API specification</h1>
52
53The API allows third party software to interface with GSCF and connected modules.
54
55<h2>prerequisites</h2>
56    <li>a valid username / password with role ROLE_CLIENT (see <a href="#authenticate">authenticate</a>)</li>
57    <li>a shared secret (used to calculate the validation md5 hash)</li>
58    <li>a deviceID / clientID (look <a href="https://github.com/4np/UIDevice-with-UniqueIdentifier-for-iOS-5" target="_new">here</a> for iOS)</li>
59
60<h2>available API calls</h2>
61    <li><a href="#authenticate">authenticate</a> - set up / synchronize client-server session</li>
62    <li><a href="#getStudies">getStudies</a> - fetch all (readable) studies</li>
63    <li><a href="#getSubjectsForStudy">getSubjectsForStudy</a> - fetch all subjects in a given study</li>
64    <li><a href="#getAssaysForStudy">getAssaysForStudy</a> - fetch all assays in a given study</li>
65
66<a name="authenticate"></a>
67<h1>authenticate</h1>
68<h3>url: <g:createLink controller="api" action="authenticate" absolute="true" /></h3>
69<p>
70    Authenticate a client using <a href="http://en.wikipedia.org/wiki/Basic_access_authentication" target="_new">HTTP BASIC authentication</a>.
71    This API call is used to:
72    <li>initially set up a client/server session</li>
73    <li>re-synchronise client/server sessions that become out of sync (e.g. <i>sequence</i> differences)</li>
74<p>
75
76<p>
77    After successful authentication, a session token is returned which should the client should store locally. This session token
78    should be used in all subsequent calls to calculate the validation md5 hash.
79</p>
80<p>
81    This call should also be performed whenever a client/server sessions becomes out of sync (e.g. the client's sequence count
82    differs from the server's sequence count) as the server's sequence count will be returned after successfully authenticating.
83    For security reasons this api method is designed to be called only once (or when sessions are out of sync) as HTTP BASIC authentication
84    is not really secure (if someone is able to sniff your traffic, the authentication md5 hash is easily stolen). API calls are
85    validated using the calculated md5 hash.
86</p>
87<p>
88    Every subsequent request the client does, needs to contain the validation MD5 hash, which is a MD5 sum of the concatenation of the device token,
89    the request sequence and a shared secret (e.g. <i>md5sum( token + sequence + shared secret )</i> ).<br/>
90    <i>Note that in order to be able to successfully authenticate or use the API in general, the user should have the ROLE_CLIENT assigned!</i>
91
92    <h2>Request parameters</h2>
93    <table>
94        <thead>
95            <th>argument</th>
96            <th>type</th>
97            <th>length</th>
98            <th>description</th>
99            <th>example</th>
100            <th>required</th>
101        </thead>
102        <tr>
103            <td>deviceID</td>
104            <td>string</td>
105            <td>32</td>
106            <td>a unique ID of the client device / application performing the call (<a href="https://github.com/4np/UIDevice-with-UniqueIdentifier-for-iOS-5" target="_new">iOS example</a>)</td>
107            <td>9ae87836-d38d-4b86-be6a-eff93f2b049a</td>
108            <td>yes</td>
109        </tr>
110    </table>
111
112    <h2>Reply parameters</h2>
113    <table>
114        <thead>
115            <th>argument</th>
116            <th>type</th>
117            <th>length</th>
118            <th>description</th>
119            <th>example</th>
120        </thead>
121        <tr>
122            <td>token</td>
123            <td>string</td>
124            <td>36</td>
125            <td>a unique token for setting up a client session</td>
126            <td>9ae87836-d38d-4b86-be6a-eff93f2b049a</td>
127        </tr>
128        <tr>
129            <td>sequence</td>
130            <td>int</td>
131            <td>-</td>
132            <td>the api call count for this session</td>
133            <td>231</td>
134        </tr>
135    </table>
136
137    <h2>example reply</h2>
138    <blockquote>
139        {"token":"78b070a6-e68c-436e-a81b-2db08840e809","sequence":0}
140    </blockquote>
141</p>
142
143<a name="getStudies"></a>
144<h1>getStudies</h1>
145<h3>url: <g:createLink controller="api" action="getStudies" absolute="true" /></h3>
146<p>
147    Returns the studies which are <i>readable</i> and/or <i>writable</i> for the client. If the client should get access to a particular
148    study, the client's username (used to authenticate) should be added as a reader to the study.
149
150    <h2>Request parameters</h2>
151    <table>
152        <thead>
153            <th>argument</th>
154            <th>type</th>
155            <th>length</th>
156            <th>description</th>
157            <th>example</th>
158            <th>required</th>
159        </thead>
160        <tr>
161            <td>deviceID</td>
162            <td>string</td>
163            <td>36 (max)</td>
164            <td>a unique ID of the client device / application performing the call</td>
165            <td>9ae87836-d38d-4b86-be6a-eff93f2b049a</td>
166            <td>yes</td>
167        </tr>
168        <tr>
169            <td>validation</td>
170            <td>string</td>
171            <td>-</td>
172            <td><a href="http://www.miraclesalad.com/webtools/md5.php" target="_new">md5sum</a>( token + sequence + shared secret )</td>
173            <td>9ae87836d38d4b86be6aeff93f2b049a</td>
174            <td>yes</td>
175        </tr>
176    </table>
177
178    <h2>example reply</h2>
179    <blockquote>
180        {"count":2,"studies":[{"token":"f2e085fb-9138-4ebe-a59f-82f1bdc21d7e","title":"NuGO PPS human study","description":"Human study performed at RRI; centres involved: RRI, IFR, TUM, Maastricht U.","subjects":11,"species":["Homo sapiens"],"assays":["Mass Sequencing module","SAM module for clinical data","Metabolomics module"],"events":1,"uniqueEvents":["start: 3 days, 22 hours, duration: 8 hours"],"samplingEvents":2,"uniqueSamplingEvents":["start: 0 seconds","start: 4 days, 6 hours"],"eventGroups":1,"uniqueEventGroups":["Root group"],"samples":22},{"token":"6b7e85b3-b174-492c-ba27-fbfb71ab9b8b","title":"NuGO PPS3 mouse study leptin module","description":"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet.","subjects":80,"species":["Mus musculus"],"assays":["SAM module for clinical data","Metabolomics module"],"events":8,"uniqueEvents":["start: 1 hour, duration: 1 week","start: 1 hour, duration: 4 weeks"],"samplingEvents":2,"uniqueSamplingEvents":["start: 1 week, 1 hour"],"eventGroups":8,"uniqueEventGroups":["10% fat + vehicle for 1 week","10% fat + leptin for 1 week","45% fat + vehicle for 1 week","45% fat + leptin for 1 week","10% fat + vehicle for 4 weeks","10% fat + leptin for 4 weeks","45% fat + vehicle for 4 weeks","45% fat + leptin for 4 weeks"],"samples":80}]}
181    </blockquote>
182</p>
183
184<a name="getSubjectsForStudy"></a>
185<h1>getSubjectsForStudy</h1>
186<h3>url: <g:createLink controller="api" action="getSubjectsForStudy" absolute="true" /></h3>
187<p>
188    Returns the subjects for a particular study
189
190    <h2>Request parameters</h2>
191    <table>
192        <thead>
193            <th>argument</th>
194            <th>type</th>
195            <th>length</th>
196            <th>description</th>
197            <th>example</th>
198            <th>required</th>
199        </thead>
200        <tr>
201            <td>deviceID</td>
202            <td>string</td>
203            <td>36 (max)</td>
204            <td>a unique ID of the client device / application performing the call</td>
205            <td>9ae87836-d38d-4b86-be6a-eff93f2b049a</td>
206            <td>yes</td>
207        </tr>
208        <tr>
209            <td>validation</td>
210            <td>string</td>
211            <td>-</td>
212            <td><a href="http://www.miraclesalad.com/webtools/md5.php" target="_new">md5sum</a>( token + sequence + shared secret )</td>
213            <td>9ae87836d38d4b86be6aeff93f2b049a</td>
214            <td>yes</td>
215        </tr>
216        <tr>
217            <td>studyToken</td>
218            <td>string</td>
219            <td>255</td>
220            <td>study token (see getStudies)</td>
221            <td>b6e0c6f4-d8db-4a43-91fa-a157d2d492f0</td>
222            <td>yes</td>
223        </tr>
224    </table>
225
226    <h2>example reply</h2>
227    <blockquote>
228        {"count":11,"subjects":[{"id":81,"name":"1","species":"Homo sapiens","Gender":"Female","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":82,"name":"2","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":83,"name":"3","species":"Homo sapiens","Gender":"Female","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":84,"name":"4","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":85,"name":"5","species":"Homo sapiens","Gender":"Female","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":86,"name":"6","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":87,"name":"7","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":88,"name":"8","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":89,"name":"9","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":90,"name":"10","species":"Homo sapiens","Gender":"Male","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null},{"id":91,"name":"11","species":"Homo sapiens","Gender":"Female","Age":null,"DOB":null,"Height":null,"Weight":null,"BMI":null,"Race":null,"Waist circumference":null,"Hip circumference":null,"Systolic blood pressure":null,"Diastolic blood pressure":null,"Heart rate":null,"Run-in-food":null}]}
229    </blockquote>
230</p>
231
232<a name="getAssaysForStudy"></a>
233<h1>getAssaysForStudy</h1>
234<h3>url: <g:createLink controller="api" action="getAssaysForStudy" absolute="true" /></h3>
235<p>
236    Returns the assays for a particular study
237
238    <h2>Request parameters</h2>
239    <table>
240        <thead>
241        <th>argument</th>
242        <th>type</th>
243        <th>length</th>
244        <th>description</th>
245        <th>example</th>
246        <th>required</th>
247        </thead>
248        <tr>
249            <td>deviceID</td>
250            <td>string</td>
251            <td>36 (max)</td>
252            <td>a unique ID of the client device / application performing the call</td>
253            <td>9ae87836-d38d-4b86-be6a-eff93f2b049a</td>
254            <td>yes</td>
255        </tr>
256        <tr>
257            <td>validation</td>
258            <td>string</td>
259            <td>-</td>
260            <td><a href="http://www.miraclesalad.com/webtools/md5.php" target="_new">md5sum</a>( token + sequence + shared secret )</td>
261            <td>9ae87836d38d4b86be6aeff93f2b049a</td>
262            <td>yes</td>
263        </tr>
264        <tr>
265            <td>studyToken</td>
266            <td>string</td>
267            <td>255</td>
268            <td>study token (see getStudies)</td>
269            <td>b6e0c6f4-d8db-4a43-91fa-a157d2d492f0</td>
270            <td>yes</td>
271        </tr>
272    </table>
273
274    <h2>example reply</h2>
275    <blockquote>
276        {"count":6,"assays":[{"token":"253ec24f-9bac-4f2b-b9cf-f84b86376a4e","name":"16S Sequencing assay","module":"Mass Sequencing module","Description":null},{"token":"4df2f49d-1d8c-48bd-8ebd-d267164948ec","name":"18S Sequencing assay","module":"Mass Sequencing module","Description":null},{"token":"828cf2d6-d797-484b-82f9-df9933d76d77","name":"Glucose assay after","module":"SAM module for clinical data","Description":null},{"token":"d68e8fed-41ca-4408-9d8e-f3598eca9183","name":"Glucose assay before","module":"SAM module for clinical data","Description":null},{"token":"32945764-6c5e-497c-8b1e-0d5e0dfa8221","name":"Lipidomics profile after","module":"Metabolomics module","Description":null,"Spectrometry technique":"GC/MS"},{"token":"92f42f77-1c13-4b25-aa57-b444e355fbf4","name":"Lipidomics profile before","module":"Metabolomics module","Description":null,"Spectrometry technique":"GC/MS"}]}
277    </blockquote>
278</p>
279</div>
280</body>
281</html>
Note: See TracBrowser for help on using the repository browser.