Profiles - Goals

Goals Overview

Dashboard widget

GET ‎https://<domain>/<api prefix>/<version>/profiles/overview/

This endpoint will return goals overview data (dashboard widget).

Query Parameters

NameTypeDescription

profile_id

string

Profile Id

Headers

NameTypeDescription

apikey*

string

Apikey

Authorization*

string

Bearer access token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "user_goals": {
            "<goal_key>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>",
                "current": <current>,
                "percentage": <percentage>,
                "difference": <difference>
            },
            ...
        },
        "eligibleforupdate": <eligibleforupdate_status>,
        "profiles": [
            {
                "id": <profile_id>,
                "profilename": "<profile_name>"
            },
            ...
        ]
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/profiles/overview/',
  'headers': {
    'apikey': '<apikey>',
    'api-signature': '<api-signature>',
    'Authorization': 'Bearer <access token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/profiles/overview/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'api-signature: <api-signature>',
    'Authorization: Bearer <access token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

User Goals Leaderboard

GET ‎https://<domain>/<api prefix>/<version>/profiles/user/goals-leaderboard/

This API endpoint will return user goal leaderboard data.

Query Parameters

NameTypeDescription

profile

string

profile id

goal

string

goal keyword

Headers

NameTypeDescription

apikey*

string

Apikey

Authorization*

string

Bearer access token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "courseList": [
            {
                thumbnail: "<thumbnail>",
                duration: <duration>,
                title: "<title>",
                short_description: "<short_description>",
                detail_url: "<detail_url>"
            },
            ...
        ],
        "goals": {
            "<goal_key>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>"
            },
            ...
        },
        "selected_goal": "<selected_goal_keyword>",
        "selected_profile": <selected_profile_id>,
        "profiles_leader_board_data": {
            "<user_id>": {
                "name": "<name>",
                "level": <level>,
                "overall": <overall>,
                "percentage": <percentage>,
                "image": "<profile_image>"
            },
            ...
        },
        "goal_leader_board_user_data": {
            "<user_id>": {
                "value": <value>,
                "image": "<profile_image>",
                "firstname": "<firstname>",
                "surname": "<surname>",
                "percentage": <percentage>
            },
            ...
        },
        "current_goal_info": {
            "<goal_keyword>": {
                "period": "<period>",
                "maximum": <maximum>,
                "minimum": <minimum>,
                "display_name": "<display_name>",
                "currency_code": "<currency_code>",
                "current": <current>,
                "percentage": <percentage>,
                "difference": <difference>
            }
        },
        "goal_status": {
            "goal": "<max_goal_value>",
            "achieved": "<achieved_value>",
            "status_text": "<status_text>"
        },
        "current_goal_details": {
            "variants": [
                {
                    "step": "<step>",
                    "active_link": "<active_link>",
                    "recommended_course": "<recommended_course>",
                    "recommended_article": "<recommended_article>"
                },
                ...
            ]
        },
        "profiles": [
            {
                "id": <profil_id>,
                "profilename": "<profile_name>"
            },
            ...
        ]
    }
}

Sample Code

Node

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://<domain>/<api prefix>/<version>/profiles/user/goals-leaderboard/',
  'headers': {
    'apikey': '<apikey>',
    'api-signature': '<api-signature>',
    'Authorization': 'Bearer <access-token>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/profiles/user/goals-leaderboard/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'apikey: <apikey>',
    'api-signature: <api-signature>',
    'Authorization: Bearer <access-token>',
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

profile

Invalid profile id.

400

Validation Error

goal

Invalid goal keyword.

Last updated