Quickstart Guide


The Nike+ API is open only to Nike+ partners. For inqueries regarding partnerships, refer to the Contact page. Also, the application is required to whitelist the Callback URI(s) prior to the authentication flows working successfully.

Loading the SDK

The below script block can be added to a web application to load the Nike+ JavaScript SDK. This must be inserted before the closing body tag. Implementing the code this way will load the JavaScript asynchronously and not block any other elements loading on the page.
        var np,nid="nikeplus-sdk",d=document,
        if (d.getElementById(nid)) {return;}

Using the SDK

Initialize the SDK

Once the Nike+ JavaScript SDK has loaded, the SDK will call window.nikeplusSDKAsyncInit if it this has been defined by the web application. Any code the web application needs is run when the SDK is ready, should be defined in the nikeplusSDKAsyncInit function. The application will want to call NIKEPLUS.init in that function with a minimum of the application's Client ID and redirect URI.
function nikeplusSDKAsyncInit() {
        client_id: "your_client_id",
        redirect_uri: "http://your_redirect_uri.com/redirect.html",
        authSuccess: function(authData){}

sitePrefix Setting

If multiple applications are going to be using the same Client ID on multiple sites, and the required behavior is to not use the same authentication data for a user on both sites, the sitePrefix setting will need to be used. The SDK stores authentication data with a namespace created by the combination of the data with the client id. Adding a unique sitePrefix per site further namespaces the data with the provided sitePrefix.

Possible NIKEPLUS.init Settings

Setting Values Default Required Description
client_id String   Yes The client id provided to you by Nike.
    If you have multiple sites with the same client id, use this site prefix to keep sessions separate per site. This is a unique string per site
  When True, the login screen will open in a new window and the OAuth redirect will happen in that window. The application will need to handle the closing of the window after the redirect. When False, the login screen will load in the existing window, and redirect in this window.
    Returned on the OAuth redirect and used to maintain state through the redirect and prevent cross-site forgery.
response_type String token   Two possible values: token or code. This determines the OAuth flow to be used for authorization. When token, the implicit flow will be used. When code, the authorization code will be used.
redirect_uri String   Yes The redirect URI after authorization. All redirect URIs need to be whitelisted.
authSuccess Function     Called after a successful redirect when response type is token. It will be passed an object with all the data from the authorization.
authError Function     Called after an error redirect, and the response type is token. It will be passed an object with error data from the URL.