WOCAT Website API » History » Version 1
Lukas Vonlanthen, 26 May 2016 10:35
1 | 1 | Lukas Vonlanthen | h1. WOCAT Website API |
---|---|---|---|
2 | |||
3 | Old version: https://redmine.cde.unibe.ch/projects/wocat-cms/wiki/WebServicesAuthentificationAddress |
||
4 | |||
5 | h2. Requirements: |
||
6 | |||
7 | - All requests over encrypted connection (SSL) |
||
8 | - All responses as JSON |
||
9 | - Authentication for service is needed (eg. token authentication http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication) |
||
10 | - Documentation is available (eg. http://django-rest-swagger.readthedocs.io/en/latest/) |
||
11 | |||
12 | |||
13 | h2. End points: |
||
14 | |||
15 | - Authentication |
||
16 | |||
17 | /[v1]/authentication |
||
18 | Method: POST |
||
19 | Data: |
||
20 | - username |
||
21 | - password |
||
22 | Response: |
||
23 | - JSON user object if login successful |
||
24 | - Response with HTTP status code 401 if login not successful |
||
25 | |||
26 | |||
27 | - List of users (with search) |
||
28 | |||
29 | /[v1]/users |
||
30 | Method: GET |
||
31 | Query parameters: |
||
32 | - name (username or first/lastname) |
||
33 | Response: |
||
34 | - List of JSON user objects |
||
35 | { |
||
36 | "users": [ |
||
37 | // List of JSON user objects |
||
38 | ], |
||
39 | "count": 2 // the total count (without limit) |
||
40 | } |
||
41 | |||
42 | |||
43 | - Details of user |
||
44 | |||
45 | /[v1]/users/[id] |
||
46 | Method: GET |
||
47 | URL parameter: |
||
48 | - id |
||
49 | Response: |
||
50 | - JSON user object if found |
||
51 | - Response with HTTP status code 404 if not found |
||
52 | |||
53 | |||
54 | - List of institutions |
||
55 | |||
56 | /[v1]/institutions |
||
57 | Method: GET |
||
58 | Response: |
||
59 | - List of JSON institution objects |
||
60 | { |
||
61 | "users": [ |
||
62 | // List of JSON institution objects |
||
63 | ], |
||
64 | "count": 2 // the total count (without limit) |
||
65 | } |
||
66 | |||
67 | |||
68 | - List of projects |
||
69 | |||
70 | /[v1]/projects |
||
71 | Method: GET |
||
72 | Response: |
||
73 | - List of JSON project objects |
||
74 | { |
||
75 | "users": [ |
||
76 | // List of JSON project objects |
||
77 | ], |
||
78 | "count": 2 // the total count (without limit) |
||
79 | } |
||
80 | |||
81 | |||
82 | h2. Response formats |
||
83 | |||
84 | Format of JSON user object: |
||
85 | |||
86 | { |
||
87 | "uid": 1055, |
||
88 | "username": "kurt.gerber@cde.unibe.ch", |
||
89 | "first_name": "Kurt", |
||
90 | "last_name": "Gerber", |
||
91 | "usergroup": [ |
||
92 | "wocat", |
||
93 | "unccd" |
||
94 | ], |
||
95 | "address": "Hallerstrasse 10", |
||
96 | "zip": "3012", |
||
97 | "city": "Bern", |
||
98 | "country": "Switzerland", |
||
99 | "institution": { |
||
100 | "name": "CDE", |
||
101 | "id": 1 |
||
102 | } |
||
103 | } |
||
104 | |||
105 | Format of JSON institution object: |
||
106 | |||
107 | { |
||
108 | "name": "CDE", |
||
109 | "id": 1 |
||
110 | } |
||
111 | |||
112 | Format of JSON project object: |
||
113 | |||
114 | { |
||
115 | "name": "DRR project", |
||
116 | "id": 1 |
||
117 | } |
||
118 | |||
119 | |||
120 | h2. Open questions: |
||
121 | |||
122 | - Can users have more than 1 institution? |
||
123 | - SSO with cookie? |
||
124 | - Authentication token periodically changing? |