Skip to content

Visualization APIs

Joshua Selsky edited this page Aug 19, 2013 · 19 revisions

The out-of-the-box visualization APIs dispatch to opencpu in order to generate statistical plots using R. When a request is sent to a visualization API, it is proxied by ohmage to opencpu. opencpu then calls back into ohmage and uses survey_response/read to retrieve data to plot.

What does it do?

Returns a PNG image showing the number of survey responses for each survey within a particular campaign.

URI

/viz/survey_response_count/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) campaign_urn = The URN of the campaign to aggregate survey responses from.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) aggregate = An integer indicating how many days worth of data to aggregate into one point (or bar in a bar chart).

Example POST

POST /app/viz/survey_response_count/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=b1457284-536d-11e1-a713-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30&aggregate=5" https://dev.ohmage.org/app/viz/survey_response_count/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing the number of survey responses for each survey by privacy state within a particular campaign.

URI

viz/survey_responses_privacy_state/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) campaign_urn = The URN of the campaign to aggregate survey responses from.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) aggregate = An integer indicating how many days worth of data to aggregate into one point (or bar in a bar chart).

Example POST

POST /app/viz/survey_responses_privacy_state/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=c74f82f4-536d-11e1-b1a5-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &start_date=2012-01-01
  &end_date=2012-02-01

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30&aggregate=5" https://dev.ohmage.org/app/viz/survey_responses_privacy_state/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing the number of survey responses for each survey within a particular campaign as a time series.

URI

viz/survey_responses_privacy_state_time/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) campaign_urn = The URN of the campaign to aggregate survey responses from.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".

Example POST

POST /app/viz/survey_responses_privacy_state_time/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=23a2fbc4-5370-11e1-baed-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &start_date=2012-01-01
  &end_date=2012-02-01

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30" https://dev.ohmage.org/app/viz/survey_responses_privacy_state_time/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing a count of prompt responses for an individual prompt.

URI

viz/prompt_distribution/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) prompt_id = The prompt ID of indicating which data to plot.
  • (r) campaign_urn = The URN of the campaign containing the above prompt_id.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".

Example POST

POST /app/viz/prompt_distribution/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=f6014f02-5371-11e1-b1f1-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &start_date=2012-01-01
  &end_date=2012-02-01
  &prompt_id=sleepTime

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30&prompt_id=sleepTime" https://dev.ohmage.org/app/viz/prompt_distribution/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing a time series of prompt responses for an individual prompt.


URI

viz/prompt_timeseries/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) prompt_id = The prompt ID of indicating which data to plot.
  • (r) campaign_urn = The URN of the campaign containing the above prompt_id.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) aggregate = An integer indicating how many days worth of data to aggregate into one point (or bar in a bar chart).

Example POST

POST /app/viz/prompt_timeseries/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=f6014f02-5371-11e1-b1f1-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &start_date=2012-01-01
  &end_date=2012-02-01
  &prompt_id=snackCost

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30&prompt_id=snackCost" https://dev.ohmage.org/app/viz/prompt_timeseries/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing a time series of a single user's prompt responses for an individual prompt.

URI

viz/user_timeseries/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) user = The username of the user whose data should appear in the plot.
  • (r) prompt_id = The prompt ID of indicating which data to plot.
  • (r) campaign_urn = The URN of the campaign containing the prompt and to which the user belongs.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".

Example POST

POST /app/viz/user_timeseries/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=f6014f02-5371-11e1-b1f1-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &prompt_id=snackCost
  &user=winston.churchill

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&start_date=2012-03-01&end_date=2012-03-30&prompt_id=snackCost&user=winston.churchill" https://dev.ohmage.org/app/viz/prompt_timeseries/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing a scatter plot of two different prompts.

URI

viz/scatter_plot/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) prompt_id = The prompt ID of indicating which data to plot.
  • (r) prompt2_id = The prompt ID of indicating which data to plot.
  • (r) campaign_urn = The URN of the campaign containing the prompts.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".

Example POST

POST /app/viz/scatter_plot/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=f6014f02-5371-11e1-b1f1-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &prompt_id=whoDidYouSnackWith
  &prompt2_id=snackHealthQuality

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&prompt_id1=whoDidYouSnackWith&prompt_id2=snackHealthQuality" https://dev.ohmage.org/app/viz/scatter_plot/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Returns a PNG image showing a 2D density plot of two different prompts. The plot below contains the same data as the scatter plot example above.

URI

viz/2d_density/read

Access Rules

The access rules are the same as those used for survey_response/read.

Input Parameters

  • (r) auth_token = The authentication token for the requester. May also be set using the Set-Cookie header.
  • (r) client = A short description of the software client making the request.
  • (r) prompt_id = The prompt ID of indicating which data to plot.
  • (r) prompt2_id = The prompt ID of indicating which data to plot.
  • (r) campaign_urn = The URN of the campaign containing the prompts.
  • (r) width = The desired width of the resulting image.
  • (r) height = The desired height of the resulting image.
  • (o) privacy_state = "shared" to plot only shared responses.
  • (o) start_date = A start date for the time range of the request. It must be of the format "yyyy-MM-dd".
  • (o) end_date = A end date for the time range of the request. It must be of the format "yyyy-MM-dd".

Example POST

POST /app/viz/2d_density/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=f6014f02-5371-11e1-b1f1-c82a142568c4
  &client=ohmage-gwt
  &campaign_urn=urn:some:campaign
  &width=800
  &height=600
  &prompt_id=whoDidYouSnackWith
  &prompt2_id=snackHealthQuality

cURL Example

curl -v -d "auth_token=token&campaign_urn=urn:some:campaign&client=ohmage-gwt&width=800&length=600&prompt_id1=whoDidYouSnackWith&prompt_id2=snackHealthQuality" https://dev.ohmage.org/app/viz/2d_density/read

Output Format

Success

The requested plot is returned as an PNG image in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

Clone this wiki locally