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