WOCAT Website API » History » Version 3
Lukas Vonlanthen, 26 May 2016 11:54
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 | 3 | Lukas Vonlanthen | h3. Authentication |
16 | 1 | Lukas Vonlanthen | |
17 | 3 | Lukas Vonlanthen | * URL: @/[v1]/authentication@ |
18 | * Method: POST |
||
19 | * Data: |
||
20 | > * username |
||
21 | > * password |
||
22 | * Response: |
||
23 | > * JSON user object if logi> successful |
||
24 | > * Response with HTTP status code 401 if login not successful |
||
25 | 1 | Lukas Vonlanthen | |
26 | |||
27 | 3 | Lukas Vonlanthen | h3. List of users (with search) |
28 | 1 | Lukas Vonlanthen | |
29 | 3 | Lukas Vonlanthen | * URL: @/[v1]/users@ |
30 | * Method: GET |
||
31 | * Query parameters: |
||
32 | > * name (username or first/lastname) |
||
33 | * Response: |
||
34 | > * List of JSON user objects |
||
35 | > <pre> |
||
36 | { |
||
37 | "users": [ |
||
38 | // List of JSON user objects |
||
39 | ], |
||
40 | "count": 2 // the total count (without limit) |
||
41 | } |
||
42 | </pre> |
||
43 | 1 | Lukas Vonlanthen | |
44 | 3 | Lukas Vonlanthen | h3. Details of user |
45 | 1 | Lukas Vonlanthen | |
46 | 3 | Lukas Vonlanthen | * URL: @/[v1]/users/[id]@ |
47 | * Method: GET |
||
48 | * URL parameter: |
||
49 | > * id |
||
50 | * Response: |
||
51 | > * JSON user object if found |
||
52 | > * Response with HTTP status code 404 if not found |
||
53 | 1 | Lukas Vonlanthen | |
54 | |||
55 | 3 | Lukas Vonlanthen | h3. List of institutions |
56 | 1 | Lukas Vonlanthen | |
57 | 3 | Lukas Vonlanthen | * URL: @/[v1]/institutions@ |
58 | * Method: GET |
||
59 | * Response: |
||
60 | > * List of JSON institution objects |
||
61 | > <pre> |
||
62 | { |
||
63 | "users": [ |
||
64 | // List of JSON institution objects |
||
65 | ], |
||
66 | "count": 2 // the total count (without limit) |
||
67 | } |
||
68 | </pre> |
||
69 | 1 | Lukas Vonlanthen | |
70 | |||
71 | 3 | Lukas Vonlanthen | h3. List of projects |
72 | 1 | Lukas Vonlanthen | |
73 | 3 | Lukas Vonlanthen | * URL: /[v1]/projects |
74 | * Method: GET |
||
75 | * Response: |
||
76 | > * List of JSON project objects |
||
77 | > <pre> |
||
78 | { |
||
79 | "users": [ |
||
80 | // List of JSON project objects |
||
81 | ], |
||
82 | "count": 2 // the total count (without limit) |
||
83 | } |
||
84 | </pre> |
||
85 | 1 | Lukas Vonlanthen | |
86 | 2 | Lukas Vonlanthen | |
87 | h2. Response formats |
||
88 | |||
89 | Format of JSON user object: |
||
90 | 1 | Lukas Vonlanthen | |
91 | { |
||
92 | "uid": 1055, |
||
93 | "username": "kurt.gerber@cde.unibe.ch", |
||
94 | "first_name": "Kurt", |
||
95 | "last_name": "Gerber", |
||
96 | "usergroup": [ |
||
97 | { |
||
98 | "name": "UNCCD Focal Point", |
||
99 | "unccd_country": "CHE" |
||
100 | } |
||
101 | ], |
||
102 | "address": "Hallerstrasse 10", |
||
103 | "zip": "3012", |
||
104 | "city": "Bern", |
||
105 | "country": "Switzerland", |
||
106 | "institution": { |
||
107 | "name": "CDE", |
||
108 | "id": 1 |
||
109 | } |
||
110 | } |
||
111 | |||
112 | Format of JSON institution object: |
||
113 | |||
114 | { |
||
115 | "name": "CDE", |
||
116 | "id": 1 |
||
117 | } |
||
118 | |||
119 | Format of JSON project object: |
||
120 | |||
121 | { |
||
122 | "name": "DRR project", |
||
123 | "id": 1 |
||
124 | } |
||
125 | |||
126 | |||
127 | h2. Open questions: |
||
128 | |||
129 | - Can users have more than 1 institution? |
||
130 | - SSO with cookie? |
||
131 | - Authentication token periodically changing? |