home api list

Hexostore API Documentation

range

/api/range/

List methods: get, post, patch

Detail methods: get, put, patch, delete

A Range represents a period in time and is created independently from records and trainingsessions. A activitytype may be associated with a Range to give it more contextual data.

You may set a value for an activityattribute in the activityattributes field. The activityattributes field is processed only if it is provided. In this API, foreign keys are usually not updated but this field is an exception. If you supply activityattributes during a PUT or PATCH, the activityattribute values will replace/update the existing activityattribute values. If an activityattribute is missing or has a missing or null value, its value will be deleted.

If you omit the activityattributes field altogether, it is ignored. Thus passing an empty value for activityattributes will delete all the existing values whereas omitting it altogether will have no effect. An important distinction!

The status reflects the "most important" status of the records available in the Range. "Most important" means if any records contain a given status, that status is assigned to the Range. The order of importance is:

Therefore if any Records have a status of 'error', that becomes the status of the Range, if not, 'incomplete' is checked and so on. There is one more status that is possible; If no records are available, the status is 'empty'.

This resource may be requested in FIT format and TCX format in addition to the default, JSON. Specify the format you would like in the Accept header. FIT and TCX are represented by the application/vnd.ant.fit and application/vnd.garmin.tcx+xml mimetypes respectively.

We export a Range as a Fit Activity File or TCX Activity. See chapter 9 Activity File (page 47) of D00001309 FIT File Types Description Rev 1.6.pdf (available here). The TCX specification can be found at: http://www.garmindeveloper.com/schemas /tcx/v2/

We export the following for each Fit Activity:

Examples

Some examples for creating Ranges and linking them to different contexts:

Case: Create a top-level Range to incorporate a TrainingRoutine.

A post to /api/range/ of:

{
    "user": "/api/user/99/",
    "start": 362559400192,
    "end": 362559423513,
    "rank": 0,
    "context": {
        "trainingroutine": "/api/trainingroutine/1013/"
    }
}

Will yield:

{
    "id": 20279,
    "user": "/api/user/99/"
    "start": 362559400192,
    "end": 362559423513,
    "rank": 0,
    "context": {
        "activitytype": "/api/activitytype/103/"
        "targets": null,
        "trainingroutine": "/api/trainingroutine/1013/"
    },
    /*
    remainder omitted for brevity
    */
}

Case: Create a step Range within a TrainingRoutine.

A post to /api/range/ of:

{
    "user": "/api/user/99/",
    "start": 362559400192,
    "end": 362559401472,
    "rank": 1,
    "context": {
        "trainingroutine": "/api/trainingroutine/1013/",
        "step": 0
    }
}

Will yield:

{
    "id": 20279,
    "user": "/api/user/99/"
    "start": 362559400192,
    "end": 362559401472,
    "context": {
        "activitytype": "/api/activitytype/10/",
        "targets": {
            "custom_target_high": 0,
            "custom_target_low": 0,
            "duration_type": "distance",
            "duration_value": 3500,
            "intensity": "active",
            "target_type": "open",
            "target_value": 0
        },
        "trainingroutine": null
    },
    /*
    remainder omitted for brevity
    */
}

Case: create a Range linked with an activitytype and no trainingroutine

A post to /api/range/ of:

{
    "user": "/api/user/99/",
    "start": 362559400192,
    "end": 362559401472,
    "context": {
        "activitytype": "/api/activitytype/1/",
        "targets": {
            "custom_target_high": 0,
            "custom_target_low": 0,
            "duration_type": "distance",
            "duration_value": 3500,
            "intensity": "active",
            "target_type": "open",
            "target_value": 0
        }
    }
}

Will yield:

{
    "id": 20279,
    "user": "/api/user/99/"
    "start": 362559400192,
    "end": 362559401472,
    "context": {
        "activitytype": "/api/activitytype/1/",
        "targets": {
            "custom_target_high": 0,
            "custom_target_low": 0,
            "duration_type": "distance",
            "duration_value": 3500,
            "intensity": "active",
            "target_type": "open",
            "target_value": 0
        }
        "trainingroutine": null
    },
    /*
    remainder omitted for brevity
    */
}

The targets are optional, so a post to /api/range/ of:

{
    "user": "/api/user/99/",
    "start": 362559400192,
    "end": 362559401472,
    "context": {
        "activitytype": "/api/activitytype/1/"
    }
}

Will yield:

{
    "id": 20279,
    "user": "/api/user/99/"
    "start": 362559400192,
    "end": 362559401472,
    "context": {
        "activitytype": "/api/activitytype/1/",
        "targets": null,
        "trainingroutine": null
    },
    /*
    remainder omitted for brevity
    */
}

Fields

activitytype:

A reference to activitytype. Maybe specified by URI or ID. Using a URI is recommended.

This field is readonly.

created:

Created automatically

This field is readonly.

duration:

An integer representing the desired duration in seconds

This field is readonly.

end:

An integer indicating the number of 256ths of a second that have passed since Jan 1, 1970 UTC, ie. a traditional timestamp, multiplied by 256.

This field may be blank

This field may be null

end_date:

A date & time as a string. Ex: "2010-11-10T03:07:43"

This field is readonly.

id:

The primary key for this resource. Integer data. Ex: 2673

This field is readonly.

labels:

Many related resources. Can be either a list of URIs or list of individually nested resource data.

This field is returned fully populated.

This field may be blank

This field may be null

last_modified:

A date & time as a string. Ex: "2010-11-10T03:07:43"

This field is readonly.

metrics:

This field will contain an array of the metrics specified in include_metrics. If this argument is not supplied or there are no metrics for the given Range, it will be empty.

This field is readonly.

name:

Unicode string data. Ex: "Hello World"

This field may be blank

This field will default to: '' (empty string)

note:

Unicode string data. Ex: "Hello World"

This field may be blank

This field will default to: '' (empty string)

parent:

A reference to range. Maybe specified by URI or ID. Using a URI is recommended.

This field may be blank

This field may be null

ranges:

Contains child ranges. This field is only populated in the detail view. Ranges in a list of ranges will not contain this attribute.

This field is readonly.

rank:

Integer data. Ex: 2673

This field may be blank

This field will default to: 0

resource_uri:

The unique URI where the object resides.

This field is readonly.

start:

An integer indicating the number of 256ths of a second that have passed since Jan 1, 1970 UTC, ie. a traditional timestamp, multiplied by 256.

start_date:

A date & time as a string. Ex: "2010-11-10T03:07:43"

This field is readonly.

status:

The status as derived from the Records available in this Range.

This field is readonly.

trainingroutine:

A reference to trainingroutine. Maybe specified by URI or ID. Using a URI is recommended.

This field is readonly.

user:

A user. Maybe specified by URI, email, or ID. Using a URI is recommended.

Filtering Options

activitytype: exact, in, isnull

duration: exact, in, range, gt, gte, lt, lte

end: exact, range, gt, gte, lt, lte

id: exact, in, gt, gte, lt, lte, range

include_autodetected: true

If provided (regardless of the value), return Ranges created by the autodetection algorithms

include_histograms: exact

This is not a filtering field but a comma-separated list of histogram IDs returned for the Range. See histograms available at: histogram

include_metrics: exact

This is not a filtering field but a comma-separated list of metric IDs returned for the Range. See metrics available at: metric

labels: exact, in

last_modified: exact, in, range, gt, gte, lt, lte

rank: exact, in, gt, gte, lt, lte, range

show_all: exact

If provided (regardless of the value), system-only ranges are included in the results.

start: exact, range, gt, gte, lt, lte

trainingroutine: ALL_WITH_RELATIONS

user: exact, in, gt, gte, lt, lte, range

Sorting Options

id, start, end, user, trainingroutine, rank, duration, last_modified

© 2014 by CarrĂ© Technologies Inc.