Skip to content

A Simple API for Patient-Controlled Health Data Aggregation, Sharing, and Monetization

License

Notifications You must be signed in to change notification settings

curedao/curedao-sdk-javascript

Repository files navigation

CureDAO Unified Health API Javascript SDK

JavaScript client for the CureDAO community-owned platform for crowdsourced clinical research

Getting Started

Authentication

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.

Option 1: Use Demo Data

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.

Option 2: Access Your Own Data

  • Go to the Settings
  • Click copy your Personal Access Token
  • Include it in your API requests using the Authorization header in the format Bearer YOUR_TOKEN_HERE

Option 3: Use it in Your Own App

  • Go to the App Builder
  • Click New App and fill out the form
  • Follow the OAuth integration instructions in the Integration Guide link

Common API Usage Examples

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:

How to Get Variables

How to Get a Variable

Save a Measurement

Get Measurements

Using this SDK Library

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);

OAuth

  • 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

About

A Simple API for Patient-Controlled Health Data Aggregation, Sharing, and Monetization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published