JavaScript client for the CureDAO community-owned platform for crowdsourced clinical research
To use the CureDAO API, you first need to get an access token as described below. Once you have the token, include it in any of the API requests documented here using the Authorization
header in the format Bearer YOUR_TOKEN_HERE
.
If you don't have your own data yet, you can use the access token demo
in the Authorization
header in the format Bearer demo
.
- Go to the Settings
- Click copy your Personal Access Token
- Include it in your API requests using the
Authorization
header in the formatBearer YOUR_TOKEN_HERE
- Go to the App Builder
- Click
New App
and fill out the form - Follow the OAuth integration instructions in the
Integration Guide
link
Instead of using this SDK, you can also use the requests in our interactive API documenation. Just click the dots to the right of the "LANGUAGE" section and select Node
or Javascript
. Then you can just copy the request for usage in your project.
Here are some common usages:
- Get Units
- Get Variables
- Get Variable Categories
- Get a Specific Variable
- Save a Measurement
- Get Measurements
Please follow the installation instruction and execute the following JS code:
var CureDaoApi = require('cure_dao_unified_health_api');
var defaultClient = CureDaoApi.ApiClient.instance;
// Configure Bearer (JWT) access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN"
// Configure OAuth2 access token for authorization: curedao_oauth2
var curedao_oauth2 = defaultClient.authentications['curedao_oauth2'];
curedao_oauth2.accessToken = "YOUR ACCESS TOKEN"
var api = new CureDaoApi.AnalyticsApi()
var opts = {
'causeVariableName': "causeVariableName_example", // {String} Deprecated: Name of the hypothetical predictor variable. Ex: Sleep Duration
'effectVariableName': "effectVariableName_example", // {String} Deprecated: Name of the outcome variable of interest. Ex: Overall Mood
'causeVariableId': 56, // {Number} Variable id of the hypothetical predictor variable. Ex: 1398
'effectVariableId': 56, // {Number} Variable id of the outcome variable of interest. Ex: 1398
'predictorVariableName': "predictorVariableName_example", // {String} Name of the hypothetical predictor variable. Ex: Sleep Duration
'outcomeVariableName': "outcomeVariableName_example" // {String} Name of the outcome variable of interest. Ex: Overall Mood
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.getCorrelationExplanations(opts, callback);
- Type: OAuth
- Flow: accessCode
- Authorization URL: https://api.curedao.org/api/v1/oauth/authorize
- Scopes:
- basic: Allows you to read user info (display name, email, etc)
- readmeasurements: Allows one to read a user's measurements
- writemeasurements: Allows you to write user measurements