Project

General

Profile

CIAT API Recommendations » History » Version 1

Sebastian Manger, 18 Oct 2016 16:52

1 1 Sebastian Manger
h1. CIAT API
2
3
h2. Global 
4
5
* All resources are available via https only.
6
* All responses are in JSON. Graphics are created from the qcat application.
7
* Authentication is required for all requests.
8
* Authentication is probably done with the Authorization Header (token based)
9
* Default http response status codes are used (200, 403, 404, 500)
10
* Documentation is always good, it may be generated from the code (http://swagger.io)?
11
12
h2. Resources
13
14
There are three resources:
15
* rainfall
16
* rainy-days
17
* temperature
18
19
h2. Example
20
21
* URL: @/[v1]/<resource>@
22
* Method: GET
23
* Request params (in the get-querystring):
24
> * years: comma separated list of integers
25
> * coordinates: two points (WGS 84), comma separated (latitude, longitude)
26
> * Example request: curl -X GET -H 'Authorization: Token 007'  @https://<domain>/api/v1/rainfall/?years=2010,2020,2050&coordinates=4.6,-47@
27
* Response:
28
> * Always include 'historic' data
29
> * List of years, with monthly data:
30
<pre>
31
[
32
historic: {
33
1: 25,
34
2: 48,
35
3: 194,
36
...
37
},
38
2010: {
39
1: 20,
40
2: 25,
41
3: 15,
42
...
43
},
44
2020: {
45
...
46
}
47
]
48
</pre>
49
50
h2. Error handling
51
To be defined. 
52
* What happens in case some data is not available? Partial responses or no response at all?
53
* How verbose are request errors? e.g. request for invalid years, invalid coordinates
54
* What happens in case of request timeouts or long page loads?