API Usage
The Flow Results specification is designed to be useful in both file-based and API-based environments. File-based usage is ideal for archiving and transferring data manually between systems. However, in many production situations, interoperable systems are likely to exchange data via HTTP-based API services. When implementations provide access to Flow Results Packages and Responses via an API, the following standardized endpoints, parameters, and envelope formats shall be used.

API Authentication

Two methods of authentication are supported for clients accessing Flow Results APIs. All methods should use HTTPS for security.

Token-based authentication

Implementations must support token-based authentication, via the "Authorization" HTTP header, using the Token method. An example of a complete authorization header is:
1
Authorization: Token 0b79bab50daca910b000d4f1a2b675d604257e42
Copied!
Implementations can determine the format of tokens. The issuance, expiry, and exchange of tokens is left outside the scope of the Flow Results specification.

HTTPS Basic Auth

Providing additional support for HTTPS Basic Auth is optional, but recommended.

API Request and Response format

The Flow Results API adheres to the JSON API specification, version 1.0, an open standard for how a client should request that resources be fetched or modified, and how a server should respond to those requests, via JSON. All API requests and responses defined below reflect the JSON API norms for query parameters and pagination. JSON API also introduces an envelope structure to embed the Flow Results JSON within additional metadata. Adopting JSON API allows API clients to make use of standard JSON API libraries.

API Endpoints

Five standard API endpoints are defined for Flow Results servers operating in the Data Aggregator role. Two "push" endpoints are used to send flow results to a system playing the Data Aggregator role. Three "pull" endpoints are used to access flow results served by a Data Aggregator.
Endpoints are defined relative to a base URL chosen by the implementation, i.e.:

"Push" endpoints to submit flow results to a Data Aggregator

Publish a Package:

This endpoint is used to publish a Package descriptor for the first time to a Data Aggregator.
URL: POST [Base URL]/flow-results/packages
Query parameters: None
Request body: The request body shall specify the type of packages. It shall contain, within the attributes parameter, the JSON structure of the Descriptor.
The id of the Descriptor can be omitted (or null) if the client wants the Data Aggregator (server) to assign a new UUID for this package. If an id is provided, the client must ensure that the UUID does not conflict with a Package id that already exists on the Data Aggregator; servers must reject requests with id conflicts. This is consistent with the JSON API specification for client-generated IDs:
A server MAY accept a client-generated ID along with a request to create a resource. An ID MUST be specified with an id key, the value of which MUST be a universally unique identifier. The client SHOULD use a properly generated and formatted UUID as described in RFC 4122 [RFC4122]. A server MUST return 403 Forbidden in response to an unsupported request to create a resource with a client-generated ID.
Request example:
1
POST [Base URL]/flow-results/packages HTTP/1.1
2
Content-Type: application/vnd.api+json
3
Accept: application/vnd.api+json
4
5
{
6
"data":{
7
"type":"packages",
8
"attributes":{
9
"profile":"flow-results-package",
10
"name":"standard_test_survey",
11
"flow-results-specification":"1.0.0-rc1",
12
"created":"2015-11-26 02:59:24+00:00",
13
"modified":"2017-12-04 15:54:44+00:00",
14
"id":null,
15
"title":"Standard Test Survey",
16
"resources":[
17
{
18
"path":null,
19
"api-data-url":null,
20
"mediatype":"application/json",
21
"encoding":"utf-8",
22
"schema":{
23
"language":"eng",
24
"fields":[
25
{
26
"name":"timestamp",
27
"title":"Timestamp",
28
"type":"datetime"
29
},
30
{
31
"name":"row_id",
32
"title":"Row ID",
33
"type":"string"
34
},
35
{
36
"name":"contact_id",
37
"title":"Contact ID",
38
"type":"string"
39
},
40
{
41
"name":"session_id",
42
"title":"Session ID",
43
"type":"string"
44
},
45
{
46
"name":"question_id",
47
"title":"Question ID",
48
"type":"string"
49
},
50
{
51
"name":"response_id",
52
"title":"Response ID",
53
"type":"any"
54
},
55
{
56
"name":"response_metadata",
57
"title":"Response Metadata",
58
"type":"object"
59
}
60
],
61
"questions":{
62
"1448506769745_42":{
63
"type":"select_one",
64
"label":"Are you a woman or a man?",
65
"type_options":{
66
"choices":[
67
"Woman",
68
"Man",
69
"Other"
70
]
71
}
72
},
73
"1448506773018_89":{
74
"type":"numeric",
75
"label":"How old are you? Please enter your age in years.",
76
"type_options":{
77
"range":[
78
-99,
79
99
80
]
81
}
82
},
83
"1448506774930_30":{
84
"type":"open",
85
"label":"What was the best thing that happened to you today?",
86
"type_options":{
87
88
}
89
}
90
}
91
}
92
}
93
]
94
}
95
}
96
}
Copied!
Response:
The response from the server must adhere to the JSON API specification for POST responses.
Response example:
1
HTTP/1.1 201 Created
2
Location: https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa
3
Content-Type: application/vnd.api+json
4
5
{
6
"data":{
7
"type":"packages",
8
"id":"0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
9
"attributes":{
10
"profile":"flow-results-package",
11
"name":"standard_test_survey",
12
"flow-results-specification":"1.0.0-rc1",
13
"created":"2015-11-26 02:59:24+00:00",
14
"modified":"2017-12-04 15:54:44+00:00",
15
"id":"0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
16
"title":"Standard Test Survey",
17
"resources":[
18
{
19
"path":null,
20
"api-data-url":"https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses",
21
"mediatype":"application/json",
22
"encoding":"utf-8",
23
"schema":{
24
"language":"eng",
25
"fields":[
26
{
27
"name":"timestamp",
28
"title":"Timestamp",
29
"type":"datetime"
30
},
31
{
32
"name":"row_id",
33
"title":"Row ID",
34
"type":"string"
35
},
36
{
37
"name":"contact_id",
38
"title":"Contact ID",
39
"type":"string"
40
},
41
{
42
"name":"session_id",
43
"title":"Session ID",
44
"type":"string"
45
},
46
{
47
"name":"question_id",
48
"title":"Question ID",
49
"type":"string"
50
},
51
{
52
"name":"response_id",
53
"title":"Response ID",
54
"type":"any"
55
},
56
{
57
"name":"response_metadata",
58
"title":"Response Metadata",
59
"type":"object"
60
}
61
],
62
"questions":{
63
"1448506769745_42":{
64
"type":"select_one",
65
"label":"Are you a woman or a man?",
66
"type_options":{
67
"choices":[
68
"Woman",
69
"Man",
70
"Other"
71
]
72
}
73
},
74
"1448506773018_89":{
75
"type":"numeric",
76
"label":"How old are you? Please enter your age in years.",
77
"type_options":{
78
"range":[
79
-99,
80
99
81
]
82
}
83
},
84
"1448506774930_30":{
85
"type":"open",
86
"label":"What was the best thing that happened to you today?",
87
"type_options":{
88
89
}
90
}
91
}
92
}
93
}
94
]
95
},
96
"links":{
97
"self":"https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa"
98
}
99
}
100
}
Copied!

Publish Responses to a Package:

This endpoint is used to publish a collection of Responses for a Package to a Data Aggregator. The POST request can be used multiple times to publish additional responses in batches. Clients should use batching whenever appropriate instead of posting responses individually.
URL: POST [Base URL]/flow-results/packages/[id]/responses
Query parameters: None
Request body: The request body shall specify the type of responses. It shall contain, within the attributes parameter, a single responses attribute, containing the standard Flow Results row array.
Request example:
1
POST [Base URL]/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses HTTP/1.1
2
Content-Type: application/vnd.api+json
3
Accept: application/vnd.api+json
4
5
{
6
"data":{
7
"type":"responses",
8
"id":"0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
9
"attributes":{
10
"responses":[
11
[
12
"2015-11-26 04:33:26",
13
"11393115",
14
"10825354",
15
"47029339",
16
"1448506769745_42",
17
"Man",
18
{}
19
],
20
[
21
"2015-11-26 04:33:31",
22
"11393119",
23
"10825354",
24
"47029339",
25
"1448506773018_89",
26
"30.0000",
27
{}
28
],
29
[
30
"2015-11-26 04:33:35",
31
"11393126",
32
"10825354",
33
"47029339",
34
"1448506774930_30",
35
"https://go.votomobile.org/audiofiles/download//original",
36
{
37
"type":"audio",
38
"format":"audio/wav"
39
}
40
],
41
[
42
"2015-11-26 04:34:07",
43
"11393169",
44
"10825354",
45
"47029339",
46
"1448506769745_42",
47
"Woman",
48
{}
49
],
50
[
51
"2015-11-26 04:34:13",
52
"11393172",
53
"10825354",
54
"47029339",
55
"1448506773018_89",
56
"40.0000",
57
{}
58
]
59
]
60
}
61
}
62
}
Copied!
Response body: The response from the server must adhere to the JSON API specification for POST responses. Additionally, servers should make use of the 204 No Content response mechanism to report acceptance to clients without sending back long documents.
Response example:
1
HTTP/1.1 204 No Content
2
Content-Type: application/vnd.api+json
Copied!

"Get" endpoints to retrive flow results from a Data Aggregator

List all Flow Results Packages

This endpoint is used to request a list of the Flow Results Packages available on the server for the authorized user.
URL: GET [Base URL]/flow-results/packages
Query parameters: None
Request body: None
Request example:
1
GET [Base URL]/flow-results/packages HTTP/1.1
2
Accept: application/vnd.api+json
Copied!
Response body: The response from the server must adhere to the JSON API specification for fetching a collection of resources. The data array includes the list of package resources. Implementations may decide what summary information they want to publish in the attributes for each package.
Response example:
1
HTTP/1.1 200 OK
2
Content-Type: application/vnd.api+json
3
4
{
5
"links": {
6
"self": "https://go.votomobile.org/flow-results/packages?page%5Bsize%5D=100",
7
"next": null,
8
"previous": null
9
},
10
"data": [
11
{
12
"type": "packages",
13
"id": "0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
14
"attributes": {
15
"title": "Standard Test Survey",
16
"name": "standard_test_survey",
17
"created": "2015-11-26 02:59:24+00:00",
18
"modified": "2017-12-04 15:54:44+00:00"
19
}
20
},
21
{
22
"type": "packages",
23
"id": "d8d0275f-e108-4528-a259-d738bb626143",
24
"attributes": {
25
"title": "World Malaria Day Outbound Message",
26
"name": "world_malaria_day_outbound_message",
27
"created": "2015-05-19 15:59:25+00:00",
28
"modified": "2015-06-01 18:57:21+00:00"
29
}
30
},
31
{
32
"type": "packages",
33
"id": "d24ba50d-e3bf-4eea-b319-ddf8979979d1",
34
"attributes": {
35
"title": "Example Quotas Survey",
36
"name": "example_quotas_survey",
37
"created": "2015-12-04 05:45:51+00:00",
38
"modified": "2017-11-24 19:58:43+00:00"
39
}
40
},
41
{
42
"type": "packages",
43
"id": "ba4b5e9e-bb1f-4e92-bfd4-95868ca48b87",
44
"attributes": {
45
"title": "International Women's Day",
46
"name": "international_womens_day",
47
"created": "2017-03-08 13:57:15+00:00",
48
"modified": "2017-03-09 02:11:31+00:00"
49
}
50
}
51
]
52
}
Copied!

Get the Descriptor of a Package

This endpoint is used to request the Descriptor of a Flow Results Package
URL: GET [Base URL]/flow-results/packages/[id]
Query parameters: None
Request body: None
Request example:
1
GET [Base URL]/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa HTTP/1.1
2
Accept: application/vnd.api+json
Copied!
Response body: The response from the server must adhere to the JSON API specification for fetching a resource.
Response example:
1
HTTP/1.1 200 OK
2
Content-Type: application/vnd.api+json
3
4
{
5
"links":{
6
"self":"https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa"
7
},
8
"data":{
9
"type":"packages",
10
"id":"0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
11
"attributes":{
12
"profile":"flow-results-package",
13
"name":"standard_test_survey",
14
"flow-results-specification":"1.0.0-rc1",
15
"created":"2015-11-26 02:59:24+00:00",
16
"modified":"2017-12-04 15:54:44+00:00",
17
"id":"0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
18
"title":"Standard Test Survey",
19
"resources":[
20
{
21
"path":null,
22
"api-data-url":"https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses",
23
"mediatype":"application/json",
24
"encoding":"utf-8",
25
"schema":{
26
"language":"eng",
27
"fields":[
28
{
29
"name":"timestamp",
30
"title":"Timestamp",
31
"type":"datetime"
32
},
33
{
34
"name":"row_id",
35
"title":"Row ID",
36
"type":"string"
37
},
38
{
39
"name":"contact_id",
40
"title":"Contact ID",
41
"type":"string"
42
},
43
{
44
"name":"session_id",
45
"title":"Session ID",
46
"type":"string"
47
},
48
{
49
"name":"question_id",
50
"title":"Question ID",
51
"type":"string"
52
},
53
{
54
"name":"response_id",
55
"title":"Response ID",
56
"type":"any"
57
},
58
{
59
"name":"response_metadata",
60
"title":"Response Metadata",
61
"type":"object"
62
}
63
],
64
"questions":{
65
"1448506769745_42":{
66
"type":"select_one",
67
"label":"Are you a woman or a man?",
68
"type_options":{
69
"choices":[
70
"Woman",
71
"Man",
72
"Other"
73
]
74
}
75
},
76
"1448506773018_89":{
77
"type":"numeric",
78
"label":"How old are you? Please enter your age in years.",
79
"type_options":{
80
"range":[
81
-99,
82
99
83
]
84
}
85
},
86
"1448506774930_30":{
87
"type":"open",
88
"label":"What was the best thing that happened to you today?",
89
"type_options":{
90
91
}
92
}
93
}
94
}
95
}
96
]
97
}
98
},
99
"relationships":{
100
"responses":{
101
"links":{
102
"related":"https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses"
103
}
104
}
105
}
106
}
Copied!

Get Responses for a Package

This endpoint is used to request some or all Responses on a Flow Results Package. It supports pagination for large data sets, and a minimum set of filter parameters. Implementations may add support for additional filters.
URL: GET [Base URL]/flow-results/packages/[id]/responses
Query parameters:
  • filter[max-version]: Only included Responses recorded on versions of this Package less recent than and including this version. (This is a timestamp corresponding to the modified field of a Descriptor.)
  • filter[min-version]: Only include Responses recorded on versions of this Package more recent than and including this version. (This is a timestamp corresponding to the modified field of a Descriptor.)
  • filter[start-timestamp]: Only show Responses that were recorded after this timestamp (exclusive). (This is a timestamp in the format of RFC 3339, section 5.6, date-time.)
  • filter[end-timestamp]: Only show Responses that were recorded before and on this timestamp (inclusive). (This is a timestamp in the format of RFC 3339, section 5.6, date-time.)
  • page[size]: The requested number of responses per pagination page
  • page[afterCursor]: The response row_id to requests responses after this id, when paginating forward
  • page[beforeCursor]: The response row_id to request responses prior to this id, when paginating in reverse
Request body: None
Request example:
1
GET [Base URL]/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses?page[size]=5 HTTP/1.1
2
Accept: application/vnd.api+json
Copied!
Response body: The response from the server must adhere to the JSON API specification for fetching a resource. The type of the resource must be responses. The attributes field contains a single attribute responses, containing the results row array in Flow Results format.
Response example:
1
HTTP/1.1 200 OK
2
Content-Type: application/vnd.api+json
3
4
{
5
"data": {
6
"type": "responses",
7
"id": "0c364ee1-0305-42ad-9fc9-2ec5a80c55fa",
8
"attributes": {
9
"responses": [
10
[
11
"2015-11-26 04:33:26",
12
"11393115",
13
"10825354",
14
"47029339",
15
"1448506769745_42",
16
"Man",
17
{}
18
],
19
[
20
"2015-11-26 04:33:31",
21
"11393119",
22
"10825354",
23
"47029339",
24
"1448506773018_89",
25
"30.0000",
26
{}
27
],
28
[
29
"2015-11-26 04:33:35",
30
"11393126",
31
"10825354",
32
"47029339",
33
"1448506774930_30",
34
"https://example-test-server.com/audiofiles/download/1448506774930_30/original",
35
{
36
"type": "audio",
37
"format": "audio/wav"
38
}
39
],
40
[
41
"2015-11-26 04:34:07",
42
"11393169",
43
"10825354",
44
"47029339",
45
"1448506769745_42",
46
"Woman",
47
{}
48
],
49
[
50
"2015-11-26 04:34:13",
51
"11393172",
52
"10825354",
53
"47029339",
54
"1448506773018_89",
55
"40.0000",
56
{}
57
]
58
]
59
},
60
"relationships": {
61
"descriptor": {
62
"links": {
63
"self": "https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa"
64
}
65
},
66
"links": {
67
"self": "https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses?page%5Bsize%5D=5",
68
"next": "https://go.votomobile.org/flow-results/packages/0c364ee1-0305-42ad-9fc9-2ec5a80c55fa/responses?page%5Bsize%5D=5&page%5BafterCursor%5D=11393172",
69
"previous": null
70
}
71
}
72
}
73
}
Copied!
Last modified 9mo ago