Skip to content
Node.js Client for Runkeeper Health Graph API
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test moved user's access_token out of options and made it an input param t…

node-runkeeper - Node.js Client for Runkeeper Health Graph API

Author: Mark Soper

A client/wrapper for the Runkeeper Health Graph API:


  • node-runkeeper isn't on NPM yet, so for now the best way is cloning the respository from Github and making it available to your code
$ git clone support/runkeeper/
// in your code

Creating a client

Register your application with Runkeeper to get the credentials needed below:

var options = exports.options = {

    // Client ID: 
    // This value is the OAuth 2.0 client ID for your application.  
    client_id : "< client id >",

    // Client Secret:  
    // This value is the OAuth 2.0 shared secret for your application.   
    client_secret : "< client secret >",

    // Authorization URL:   
    // This is the URL to which your application should redirect the user in order to authorize access to his or her RunKeeper account.   
    auth_url : "",

    // Access Token URL:    
    // This is the URL at which your application can convert an authorization code to an access token. 
    access_token_url : "",

    // Redirect URI:   
    // This is the URL that RK sends user to after successful auth  
    // URI naming based on Runkeeper convention 
    redirect_uri : "< redirect uri >"


var runkeeper = require('./support/runkeeper/lib/runkeeper');

var client = new runkeeper.HealthGraph(options);

Using the client

Using any of the client's API methods assumes that it has a valid access_token. Once the Health Graph API issues your application an authorization code (see here for more information on registering an application with the Health Graph), you can request an access token.

client.getNewToken(authorization_code, function(access_token) {
  client.access_token = access_token;

  // Now you're free to do whatever you'd like with the client.

  // e.g. Get user profile information
  client.profile(function(data) {
    // data returned in JSON with format depending on type of call
    var obj = JSON.parse(data);

Extending the client

Only a few of basic API calls are currently supported. Adding support for new calls should be easy - just add entries into this dictionary in api.js

// this is from api.js
var API = exports.API = {
    "user": {"media_type": "application/",
             "uri": "/user"},
    "profile": {"media_type": "application/",
                "uri": "/profile"},
    "settings": {"media_type": "application/",
                "uri": "/settings"},
    "fitnessActivityFeed": {"media_type": "application/",
                "uri": "/fitnessActivities"},
    "fitnessActivities": {"media_type": "application/",
                "uri": "/fitnessActivities"},
Something went wrong with that request. Please try again.