Project

General

Profile

WOCAT Website API » History » Version 2

Lukas Vonlanthen, 26 May 2016 11:41

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 2 Lukas Vonlanthen
      {
93
        "name": "UNCCD Focal Point",
94
        "unccd_country": "CHE"
95
      }
96 1 Lukas Vonlanthen
    ],
97
    "address": "Hallerstrasse 10",
98
    "zip": "3012",
99
    "city": "Bern",
100
    "country": "Switzerland",
101
    "institution": {
102
      "name": "CDE",
103
      "id": 1
104
    }
105
  }
106
107
Format of JSON institution object:
108
109
  {
110
    "name": "CDE",
111
    "id": 1
112
  }
113
114
Format of JSON project object:
115
116
  {
117
    "name": "DRR project",
118
    "id": 1
119
  }
120
121
122
h2. Open questions:
123
124
- Can users have more than 1 institution?
125
- SSO with cookie?
126
- Authentication token periodically changing?