Api Rest2020-10-14T10:56:51+00:00

REST API

The REST API is the underlying interface for our official Jade API. This reference document is designed for those interested in exploring API features in detail.

[contact-form-7 id="578" title="Subscription"]

Please join our API group so that we can keep you informed of updates,
changes, down-time etc –


See Sample web interface

API index:

    • Add Log – add BGLs, Carbs, Insulin etc
    • Delete Logs – exists but not yet documented
    • Get User’s Units – get the user’s
      measurement system for BGLs, Carbs and measurements –
      deprecated, v1.0 only
    • Set settings – removed,
      now done through audit entries
      deprecated, v1.0 only
    • Set ratios – removed, now done through
      audit entries
      deprecated, v1.0 only
    • Ping – Check operation of API
    • Ping DB – check
      operation of DB
    • Log_Range
      Get the date range for log entries
    • Predict – retrieve BGL
      predictions
    • Avatar – set user’s avatar
    • Get Nonce – get one-time password for website
      login

General notes

SSL only

We require that all requests are performed over SSL.

UTF-8 encoding

Every string passed to and from the Jade API needs to be UTF-8 encoded.

Version numbers

The current version of our API is version
1.0.

Date format

All dates in the API are UTC/GMT strings in the following format:

"2012-12-31 22:31:20"

In code format, which can be used in all programming languages that support
strftime or strptime:

"%Y-%m-%d %H:%i:%s" - MySQL
"Y-m-d H:i:s" - PHP

Internally, all dates are stored in UTC/GMT time.

Result format

By default, results are returned in XML format. To specify JSON, AMF,
PLIST or YAML format, append the desired output format to the function name
e.g.

Default

.//api/1.0/login?email=email&password=password

JSON

.//api/1.0/login.json?email=email&password=password

XML

.//api/1.0/login.xml?email=email&password=password

AMF

.//api/1.0/login.amf?email=email&password=password

PLIST

.//api/1.0/login.plist?email=email&password=password

YAML

.//api/1.0/login.yaml?email=email&password=password

Error handling

ย 

Errors are returned using standard HTTP error code syntax. Any additional
info is included in the body of the return call, JSON-formatted. Error codes
not listed here are in the REST API methods listed below.

Standard API errors

Code Description
400 Bad input parameter. Error message should indicate which one
and why.
401 Bad or expired token. This can happen if the user or Jade
revoked or expired an access token. To fix, you should re-authenticate
the user.
404 File or folder not found at the specified path.
405 Request method not expected (generally should be GET or POST).
503 Your app is making too many requests and is being rate limited.
503s can trigger on a per-app or per-user basis.

Create Account

DESCRIPTION

Create a new account (app only)
URL STRUCTURE

.//api/1.0/create_account?first=first&last=last&email=email&password=password&third_party_id=tpi

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • first The user’s first name
    • last – The user’s last name
    • email – The user’s email address
      (if specified)
    • password
      – required
      The user’s password – cannot be
      blank
    • third_party_id – the third party
      id – please contact Jade for this

RETURNS

If the email is not known, an account is created but the
user must confirm it first.
If the email and password are already known (e.g. signup
instead of login by mistake), it returns a user id and an API request token for future requests.
This allows the user to signup, switch to email to confirm,
then return to the app to continue login without having to
switch screens or re-enter email and password.The
API token is a
varchar(40).Sample JSON response on success
{
"user_id": 2132,
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"message": "Ok"
}

Sample JSON response on failure

{
"result": false,
"message": "User already exists"
}

or

{
“result”: false,
“message”: “Please check your Inbox for an activation email.”
}

Login – Authentication

Jade uses a Client Login to authenticate all API requests.
See Sample. You can also obtain an API Token
via a POST request to an OAuth-style interface.

DESCRIPTION

Login and obtain authentication token for future requests.
The token is consistent and can be stored for all future
requests. It only changes when specifically requested by the
user, and is independent of name, email address or password
changes.
URL STRUCTURE

.//api/1.0/login?email=email&password=password

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • email
      required
      The user’s email address
    • password
      required
      The user’s password
    • device (optional) The device
      name e.g. Jade iOS App
    • version (optional) The version
      of the device e.g. 1.0.3.

RETURNS

A request token and user_id, or an error message. The token is a
varchar(40).Note: Message can be ‘Ok’ or a special message is returned to
support product. This must be displayed to the user
each time it occurs.Sample JSON response on success
{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"user_id": 3,
"result": true,
"message": "Ok"
}

Sample JSON response on Recall

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"user_id": 3,
"result": true,
"message": "Warning - your service needs updating as no device or version is being passed to login"
}

Sample JSON response on failure

{
"result": false,
"message": "Incorrect password, 3 attempts are left before your account is disabled."
}

Login – OAuth-style authentication

In addition to the login endpoint above, you can also obtain an API Token
via a GET or POST request to an OAuth-style interface at
.//get_token.html.

DESCRIPTION

Obtain authentication token for future requests.
The token is consistent and can be stored for all future
requests. It only changes when specifically requested by the
user, and is independent of name, email address or password
changes.
URL STRUCTURE

// or .//api/1.0/get_token.html

VERSIONS

1.0

METHOD

Note: Do NOT pass passwords unless you call the https
version of this function (it is also possible to call it via
http).

GET or POST. We prefer POST (as you may be sending
us email and password)

PARAMETERS

    • email
      optional.
      The user’s email address
    • password optional. The user’s password
    • source_site_name required. e.g.
      TicTrac
    • source_site_url required e.g.
      //www.tictrac.com
    • success_url required e.g.
      //www.tictrac.com/success.php

RETURNS

If successful, a redirect occurs to success_url with
‘?token=<API token>’ on success.token is a
varchar(40).

Logout – Remove authentication

DESCRIPTION

Removes authentication. See Sample

URL STRUCTURE

.//api/1.0/logout?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login

RETURNS

Status message.

Sample JSON response

{
"result": true,
"message": "Logout Ok"
}

Add – Log a new entry

DESCRIPTION

Add a log entry. See Sample.
Note – to convert mg/dL to mmol/L, simply divide by 18.

URL STRUCTURE

.//api/1.0/add?token=token&value=value

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • value required The value being added
    • log_type optional If omitted, a BGL log is assumed.
      See below for values of log_type
    • other optional/required, depends on log_type, see below
    • time optional. If blank, the current time is used.
      Note – UTC/GMT time.
    • notes optional Notes associated with this entry, up
      to 255 characters
    • guid optional GUID associated with this entry, up
      to 50 characters. Used to prevent duplicates when the sync process is interrupted. Does not strictly have to be a guid. Always used in the context of a user

 

Data type being logged log_type value other notes guid
BGL 1 Blood sugar level in mmol/l e.g. 4.6 The prediction in mmol/L, if known, zero if not.

Changed 2015-11-01.

Set the prediction:

(prediction in mmol/l divided by 4) – 126

Get the prediction in mmol:

(other * 4) + 126

Valid prediction range: 0 to 31.5 mmol/L.

Insulin 2 Number of units, may be decimal e.g. 0.5, 1.6, 16 Type of insulin, see below
Carbs 3 Amount of carbs in grams e.g.ย  60, 32, 3 GI type. Use 2 if unknown. Formerly was in person’s units
Protein 4 Protein amount in grams
Fat 5 Fat amount in grams
Fibre 6 Fiber amount in grams
Ketones 7 Ketone reading, no ‘%’, e.g. 7.3
Blood Pressure 8 Systolic (in mmHg)/Diastolic (in mmHg) e.g.
190/80
Note – extract returns Systolic in value
and Diastolic in other
Lab A1C/HbA1C 9 A1C reading, no ‘%’ e.g. 7.1
Notes 10 Notes text
Fructose 11 Fructose reading, no ‘%’ e.g. 8.3
Weight 12 Weight in kg e.g. 78, 105 Formerly was in person’s units
Exercise – Low Impact 13 Duration in minutes, e.g. 60
Exercise – Medium Impact 14 Duration in minutes, e.g. 45
Exercise – High Impact 15 Duration in minutes, e.g. 45
Illness 16 Duration in hours, e.g. 48
Pre-menstruation 17 Duration in hours, e.g. 48
Adrenaline 18 Duration in hours, e.g. 2
Stress 19 Duration in hours, e.g. 6
Height 20 Height in cm e.g. 188, 144 Formerly was in person’s units
A1C/HbA1C – New 21 A1C reading, in mmol/mol eg. 54 – these are
measured differently to log_type 9
BGL Sensor 22 BGLs from sensor data
in mmol/l
,
generally every 5 minutes
Formerly was in person’s units
Audit 23 Version number Audit log, describing changes to ratios or
settings
Temp Basal 24 Duration in minutes, e.g. 45 % change from 0% to 200%, stored as the
percentage minus 100, e.g. 0% is stored as -100,
100% is stored as 0, 200% is stored as +100.

–25-29 for future use–

Endocrinologist visit 30
Optometrist visit 31
Kidney test 32
Blood test 33
Nerve test 34
Diabetes educator visit 35
Dietician visit 36
Thyroid test 37
HbA1C – Home test 38 A1C reading, no ‘%’ e.g. 7.1. Less
accurate than Lab test
Custom factor 1 39 Duration in minutes, e.g. 45
Custom factor 2 40 Duration in minutes, e.g. 45
Alcohol 41
C-Peptide 42 Value in %
Fasting Plasma Glucose test 43 In mmol/l Formerly was in person’s units
Oral Glucose Tolerance test 44 In mmol/l Formerly was in person’s units
Random Plasma Glucose test 45 In mmol/l Formerly was in person’s units
Triglyceride 46 In mmol/l Formerly was in person’s units
Podiatrist visit 47
Liver test 48
Vitamin D 49 In IU
Cholesterol LDL 50
Cholesterol HDL 51
Cholesterol VLDL 52
Cholesterol Total 53
Pain 54 Duration in hours
Split Dose 55 Dose – number of units Duration in minutes divided by 5 ie value of 3 =
15 minutes
Feeling Happy 56
Feeling Hypo 57
Feeling Nervous 58
Feeling Normal 59
Feeling Sad 60
Body Fat Percentage 61 %
Body Water Percentage 62 %
Physician visit 63
Fluid Intake 64 mls

Types of insulin

 

1 Humalog
2 Lantus
3 Actrapid
4 Humulin NPH
5 Monotard
6 Novorapid
8 Humulin R
9 Levemir
12 Humalog mix 25
13 Humalog mix 50
14 Humulin 30/70
15 NovoMix 30
16 Protaphane
17 Mixtard 30/70
18 Mixtard 50/50
19 Apidra
20 Novorapid
21 Protaphane
22 Tresiba

GI Types

 

1 Low GI
2 Normal GI – use this by default
3 High GI
4 Very high GI (e.g. in the case of Hypo recovery)
5 Very low GI/Fatty (e.g. generally high fat foods such
as pizza, lasagne)

RETURNS

Id of inserted record, or error message.

Sample call

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"log_type": 1,
"time": "2014-06-03 14:00:03",
"value": 12.2,
"notes": "A big high today"
}

Sample response on success

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"message": "Ok",
"id": 1278129,
"points", 30
}

Sample response on failure

{
"result": false,
"message": "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)"
}

Add Logs – Log an array of new entries

DESCRIPTION

Adds an array of log entries. Note – to convert mg/dL to mmol/L, simply divide by 18.

URL STRUCTURE

.//api/1.0/add_logs?token=token&logs=

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • logs required An array of values being added. Each
      log entry requires:
        • log_type optional If omitted, a BGL log is assumed.
          See above for values of log_type
        • value required The value being added
        • other optional/required, depends on log_type, see
          above
        • time optional. If blank, the current time is used.
          Note – UTC/GMT time.
        • notes optional Notes associated with this entry, up
          to 255 characters

RETURNS

An array containing Ids for each inserted record (or
0 on error), and an
error message for each inserted record.

Sample call

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"logs": [ [
"log_type": 1,
"time": "2014-06-03 14:00:03",
"value": 12.2,
"notes": "A big high today" ],
[
"log_type": 2,
"time": "2014-06-03 14:01:53",
"value": 1.5,
"other": 2,
"notes": "my correction dose" ]
]
}

Sample response on success or failure

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"id": [ 92473, 92474, 92475, 0 ],
"message": [ "", "", "", "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)"]
}

Add Deleted Log entry
(for auditing)

DESCRIPTION

Add a log entry that has been deleted on the remote
device. All log entries that have been deleted must be
records for auditing purposes.

URL STRUCTURE

.//api/1.0/add_deleted?token=token&value=value

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • value required The value being added
    • log_type optional If omitted, a BGL log is assumed.
      See below for values of log_type
    • other optional/required, depends on log_type, see below
    • time optional. If blank, the current time is used.
      Note – UTC/GMT time.
    • notes optional Notes associated with this entry, up
      to 255 characters

RETURNS

Id of inserted record, or error message.

Sample response on success

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"message": "Ok",
"id": 1278129
}

Sample response on failure

{
"result": false,
"message": "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)"
}

Update – Update an entry

DESCRIPTION

  • Updates a log entry. Only the field(s) being changed need
    to be specified. Note that audit entries cannot be updated,
    although the website as the master
  • URL STRUCTURE

  • .//api/1.0/update?token=token&log_id=log_id&value=value

    VERSIONS

  • 1.0

    METHOD

  • GET, POST

    PARAMETERS

      • token
        required The request token
        obtained via login
      • log_id required The id of the log being updated
      • log_type optional if not being updated
      • value optional if not being updated
      • other optional if not being updated
      • time optional if not being updated
      • notes optional if not being updated

    RETURNS

  • Id of updated record, or error message.Sample response on success
    {
    "result": true,
    "message": "Ok",
    "id": 1278129
    }

    Sample response on failure

    {
    "result": false,
    "message": "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)"
    }

Update logs – Update an array of log entries

DESCRIPTION

Updates a log entry. Only the field(s) being changed need
to be specified. Note that audit entries cannot be updated,
although the website as the master
URL STRUCTURE

.//api/1.0/update_logs?token=token&logs=

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • logs required An array of values being added. Each
      log entry requires:
        • log_id required The id of the log being updated
        • log_type optional if not being updated
        • value optional if not being updated
        • other optional if not being updated
        • time optional if not being updated
        • notes optional if not being updated

RETURNS

An array of messages for each updated record.

Sample call

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"logs": [ [
"log_id": 1458354,
"log_type": 1,
"time": "2014-06-03 14:00:03",
"value": 35,
"notes": "A big high today" ],
[
"log_id": 1458355,
"log_type": 2,
"time": "2014-06-03 14:01:53",
"value": 1.5,
"other": 2 ]
]
}

Sample response on success or failure

{
"result": true,
"message": [ "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)", "" ]
}

Delete – Delete an entry

DESCRIPTION

Deletes a log entry, and moves it to the deleted logs for
audit purposes.

URL STRUCTURE

.//api/1.0/delete?token=token&log_id=log_id

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • log_id The id of the log being deleted

RETURNS

Status message, or error message.

Sample response on success

{
"result": 1,
"message": "Success",
}

Sample response on failure

{
"result": 2,
"message": "Not found"
}
or
{
"result": 3,
"message": "Missing log_id"
}

Units – Get user’s units –
Deprecated

DESCRIPTION

Gets the units that the user has specified for measurement
of BGLs, carbohydrate and dimensional measures such as weight
and height.
Deprecated, see Get User’s
Settings
.

URL STRUCTURE

.//api/1.0/units?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login

RETURNS

Status message.

Sample JSON response

{
"result": true,
"message": "Ok",
"carb_units": 1,
"carb_units_name": "exchanges",
"bgl_units": 1,
"bgl_units_name": "mg\/dl",
"dimensional_units": 1,
"dimensional_units_name": "Imperial",
"time_zone_offset": 600
}

Update – Update an entry

DESCRIPTION

Updates a log entry. Only the field(s) being changed need
to be specified. Note that audit entries cannot be updated,
although the website as the master
URL STRUCTURE

.//api/1.0/update?token=token&log_id=log_id&value=value

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • log_id required The id of the log being updated
    • log_type optional if not being updated
    • value optional if not being updated
    • other optional if not being updated
    • time optional if not being updated
    • notes optional if not being updated

RETURNS

Id of updated record, or error message.

Sample response on success

{
"result": true,
"message": "Ok",
"id": 1278129
}

Sample response on failure

{
"result": false,
"message": "BGL must be in range 1.2 to 28 mmol\/l, Lo or Hi (not 200)"
}

Delete – Delete an entry

DESCRIPTION

Deletes a log entry, and moves it to the deleted logs for
audit purposes.

URL STRUCTURE

.//api/1.0/delete?token=token&log_id=log_id

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login
    • log_id The id of the log being deleted

RETURNS

Status message, or error message.

Sample response on success

{
"result": 1,
"message": "Success",
}

Sample response on failure

{
"result": 2,
"message": "Not found"
}
or
{
"result": 3,
"message": "Missing log_id"
}

Units – Get user’s units

DESCRIPTION

Gets the units that the user has specified for measurement
of BGLs, carbohydrate and dimensional measures such as weight
and height

URL STRUCTURE

.//api/1.0/units?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

    • token
      required The request token
      obtained via login

RETURNS

Status message.

Sample JSON response

{
"result": true,
"message": "Ok",
"carb_units": 1,
"carb_units_name": "exchanges",
"bgl_units": 1,
"bgl_units_name": "mg\/dl",
"dimensional_units": 1,
"dimensional_units_name": "Imperial",
"time_zone_offset": 600
}

Sync_Status – Get Sync Status

DESCRIPTION

Gets the sync status – the latest settings version and the
date of the latest log entry.

URL STRUCTURE

.//api/1.0/sync_status?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    required The request token
    obtained via login

RETURNS

Status message.

Sample JSON response

{
"result": true,
"message": "Ok",
"version": 165,
"last_log": "2014-08-14 14:22:10"
}

Settings – Get user’s
settings, ratios, insulins etc

DESCRIPTION

Gets the ratios and time-sensitive values that the user has specified
for insulin correction, ratio, carb ratio etc, as well as
insulin types, percentage rates for factors, setup items
missing etc. Ratios are
delivered in time-ascending order, and the Jade dosing
algorithm assumes this order.

URL STRUCTURE

.//api/1.0/settings?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    required The request token
    obtained via login

RETURNS

An array of ratios, each containing one or more values,
the user settings, and the setup items missing.
The array called ratio_names makes life easier by
containing the mapping from index number to name of each
ratio or time-sensitive setting. The start_min field gives
the start minute measured from midnight e.g. 2:30am is
2*60+30=150 minutes. Value contains the numeric value, and
if required, other contains a lookup index.

Sample JSON response

{
"result": true,
"message": "Ok",
"version": 171,
"ratios": {
"1": [
{
"start_min": 0,
"value": 3,
"other": 0
}
],
"2": [
{
"start_min": 0,
"value": 8,
"other": 0
},
{
"start_min": 660,
"value": 12,
"other": 0
},
{
"start_min": 1080,
"value": 18,
"other": 0
}
],
"3": [
{
"start_min": 0,
"value": 6,
"other": 0
},
{
"start_min": 480,
"value": 4.8,
"other": 0
},
{
"start_min": 1140,
"value": 6,
"other": 0
}
],
"4": [
{
"start_min": 0,
"value": 0,
"other": 0
}
],
"5": [
{
"start_min": 420,
"value": 45,
"other": 1
},
{
"start_min": 630,
"value": 30,
"other": 2
},
{
"start_min": 780,
"value": 60,
"other": 3
},
{
"start_min": 930,
"value": 30,
"other": 4
},
{
"start_min": 1080,
"value": 60,
"other": 5
},
{
"start_min": 1290,
"value": 30,
"other": 6
}
],
"6": [
{
"start_min": 0,
"value": 0,
"other": 0
}
],
"7": [
{
"start_min": 1320,
"value": 17,
"other": 2
}
]
},
"ratio_names": {
"1": "Insulin sensitivity",
"2": "Carb sensitivity",
"3": "Target BGL",
"4": "Basal rate",
"5": "Meal times",
"6": "Dawn phenomenon",
"7": "Basal insulins"
},
"factors": {
"exercise1_insulin": 10,
"exercise2_insulin": 70,
"exercise3_insulin": 100,
"exercise3_sugar": 127,
"stress_insulin": -128,
"stress_sugar": 20,
"illness_insulin": -30,
"adrenaline_insulin": -30,
"pain_insulin": -30,
"premen_insulin": -5,
"custom_insulin": 20,
"custom2_insulin": 0
},
"insulins": {
"use_calc": 1,
"model_basal": 1,
"insulin_short": 1,
"insulin_short2": 0,
"insulin_long": 2,
"insulin_long2": 0,
"active_insulin_time": 4,
"insulin_increment": 0.5,
"max_bolus": 13,
"t2_return": 0
},
"carbs": {
"protein_conversion": 50,
"fat_conversion": 10,
"carb_units": 0,
"default_gi": 2,
"delayed_eating": 1,
"lowbgl_treatment": 0,
"lowbgl_grams": 3,
"liver_threshold": 0,
"liver_rate": 0
},
"other": {
"gender": 1,
"use_calc": 1,
"avatar": "085286b6dcef440d.png",
"dob": "1973-02-21",
"bgl_units": 0,
"dimensional_units": 0,
"timezone_offset": -660,
"diabetes_type_id": 1,
"role_type_id": 1,
"year_diagnosis": 1982,
"therapy_type_id": 2,
"chart_low_range": 4,
"chart_high_range": 10,
"chart_max": 18,
"chart_meter_error": 1,
"pattern_days": 5,
"setup_percent_complete": 94,
"default_exercise": 14,
"reminder_meal": 1,
"reminder_basal": 1
},
"need": [
{
"id": "meals",
"msg": "What time is coffee? Please setup your usual meal times \",
"url": "settings-meals.html"
},
{
"id": "ins_sens",
"msg": "Do you take extra insulin when your BGL is high? Please setup your Correction Ratio (AKA Insulin Sensitivity). Worksheet<\/a>\n| Video<\/a>",
"url": "settings-sensitivity-insulin.html"
}
]
}

Setup Check – Check if setup is complete

DESCRIPTION

Checks if the user’s setup is complete, and returns a list
of items that have not been completed if so.

URL STRUCTURE

.//api/1.0/setup_check?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    required The request token
    obtained via login

RETURNS

Status message.

Sample JSON response

{
"need": [
{
"id": "hba1c",
"msg": "You have not entered an A1C\/HbA1C<\/b> in the last 6 months. This is a good measure of control. Make appointment<\/a>",
"url": "logs.html?new=1&logtype_id=9"
}
],
"result": true,
"message": "Ok"
}

Ping – Check operation of API

DESCRIPTION

Check if the API is running correctly.

URL STRUCTURE

.//api/1.0/ping

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

None

RETURNS

A status message. Note – UTC/GMT time.

Sample JSON response on success

{
"result": "JadeDiabetes.com API Live, 2013-02-18 12:37:01",
"message": "Ok"
}

Sample JSON response on failure

- no result

Ping DB – Check operation of database

DESCRIPTION

Check if the database is running correctly.

URL STRUCTURE

.//api/1.0/ping_db

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

None

RETURNS

A status message. Note – UTC/GMT time.

Sample JSON response on success

{
"result": "JadeDiabetes.com DB Live, 2013-02-18 12:37:01",
"message": "Ok"
}

Sample JSON response on failure

- no result

Log_Range – Get the date range for log entries

DESCRIPTION

Gets the dates of the first and last log entries for a user,
to be used with a future Extract request. Note – UTC/GMT
time.

URL STRUCTURE

.//api/1.0/log_range?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    required The request token
    obtained via login

RETURNS

The start and end dates of the user’s logs, or null for
both dates if there are no logs. Note – UTC/GMT time.

Sample JSON response on success

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"message": "Ok",
"start_date": "2011-11-29 07:02:00",
"end_date": "2013-02-18 03:02:12"}

Sample response on failure

{
"result": false,
"message": "Invalid user"
}

Extract – Retrieve log data

DESCRIPTION

Gets the user log data, and deleted log data for a specified time range.
Date is paged – no more than max_logs per page
(defaults to 100). Note: log_deleted data only appears when the page is set to
blank, and all data is returned on the first request.

URL STRUCTURE

.//api/1.0/extract?token=token&start_date=start_date&end_date=end_date&page=page

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    required The request token
    obtained via login. Required.
  • start_date The starting date. Required. Note – UTC/GMT
    time.
  • end_date The end date. Required. Note – UTC/GMT
    time.
  • page. The page number of data to return. Optional.
    The first page of data is page 0, the next page is 1.
  • max_logs The number of rows to return. Optional.
    Defaults to 100.

RETURNS

An array of log entries, and a count of the number
found, and if on the first page, the log_deleted data. A maximum of 100 entries are returned at a time, and
further requests with the same date range and an increasing
page number are required to get more data.

Sample JSON response on success

{
"logs": [
{
"log_id": 92473,
"user_id": 1,
"logtype_id": 1,
"other": 0,
"time": "2013-01-28 11:27:00",
"value": 7.33333,
"notes": null
},
{
"log_id": 92533,
"user_id": 1,
"logtype_id": 3,
"other": 2,
"time": "2013-02-05 00:26:00",
"value": 100,
"notes": ""
}
],
"rows": 2,
"logs_deleted": [
{
"log_id": 92478
}
],
"rows_deleted": 1,
"max_logs": 100,
"result": true,
"message": "Ok"
}

Sample JSON response on final page

{
"logs": [

],
“rows”: 0,
“max_logs”: 100,
“result”: true,
“message”: “Ok”
}

Sample response on failure

{
"result": false,
"message": "Query error"
}

Predict – retrieve BGL predictions – Subscribers only

DESCRIPTION

Predicts BGL between user blood tests. Note – this call is
for PAID subscribers only.

URL STRUCTURE

.//api/1.0/predict?token=token&subscriber=subscriber_token&start_date=start_date&end_date=end_date&third_party_id=tpi

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    The request token
    obtained via login. Required
  • subscriber_token – The subscriber token issued upon
    subscription. Required
  • start_date The starting date. Required.. Note – UTC/GMT
    time.
  • end_date The end date. Optional, maximum 5 hours
    ahead. Note – UTC/GMT time.
  • third_party_id – the third party
    id – please contact Jade for this

RETURNS

An array of time-stamped BGL entries, 5 minutes apart.

Sample JSON response on success

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"prediction": [
{
"time": "2013-01-28 11:25:00",
"value": 7.3,
},
{
"time": "2013-01-28 11:30:00",
"value": 6.9,
},
....
{
"time": "2013-01-28 14:25:00",
"value": 5.0,
}
],
"rows": 120,
"result": true,
"message": "Ok"
}

Sample response on failure

{
"result": false,
"message": "Incomplete setup"
}

Import Data – import diabetes data file – Subscribers only

DESCRIPTION

Imports data from a range of diabetes data formats – subscribers only.

URL STRUCTURE

N/A - POST only:
.//api/1.0/import
token=token
subscriber=subscriber_token
upload=file_data

VERSIONS

1.0

METHOD

POST
only

PARAMETERS

  • token
    The request token
    obtained via login. Required
  • subscriber_token – The subscriber token issued upon
    subscription. Required
  • upload The data of the import file. Required.
  • date_format The format of the date, blank to
    auto-detect. e.g. %m/%d/%Y, %m-%d-%Y, %d.%m.%Y,
    %d/%m/%Y, %d-%m-%Y

RETURNS

Sample JSON response on success

{
"result": true,
"message": "372 rows imported"
}

Sample response on failure

{
"result": false,
"message": "Unknown file type"
}

Avatar –
sets user’s avatar

DESCRIPTION

Sets user’s avatar.

URL STRUCTURE

N/A - POST only:
.//api/1.0/avatar
token=token
avatar=file_data

VERSIONS

1.0

METHOD

POST


only

PARAMETERS

  • token
    The request token
    obtained via login. Required
  • avatar The data of the import file. Required.

RETURNS

Sample JSON response on success

{
"result": true,
"message": "Avatar set"
}

Sample response on failure

{
"result": false,
"message": "Avatar too big"
}

Get Nonce

DESCRIPTION

Get’s one-time password for login.

URL STRUCTURE

.//api/1.0/nonce?token=token

VERSIONS

1.0

METHOD

GET, POST

PARAMETERS

  • token
    The request token
    obtained via login. Required

RETURNS

The one-time password. The password can then be used
(once!) to login to any webpage of the JadeDiabetes.com site,
e.g.

.//reports.html?nonce=nonce

Sample JSON response on success

{
"token": "2132-gerio77fe88ihvab2jpuu8pvl7",
"result": true,
"message": "Ok",
"nonce": "2132-dsfdsgfjdsgfjdskjfdds76dsfdsf76dsf76ds6f76dsf768dsf68ds6f8ds6f8d6fds87s"
}

Sample response on failure

{
"result": false,
"message": "Invalid user"
}