Server side data model for scripts

This post lists the classes and enums available to JavaScript code running on the server (e.g. for custom activity fields with scripts). I am going to add more comments soon!

Activity

A completed activity (Ride, Run etc.). Read and write custom fields from JavaScript using activity.[field code].
All fields are metric. Times are in seconds. Speeds are in meters / sec. Temperatures are in degrees C.

  • id String
  • start_date_local String
  • type String
  • icu_ignore_time Boolean
  • icu_pm_cp Integer
  • icu_pm_w_prime Integer
  • icu_pm_p_max Integer
  • icu_pm_ftp Integer
  • icu_pm_ftp_secs Integer
  • icu_pm_ftp_watts Integer
  • icu_ignore_power Boolean
  • icu_rolling_cp Float
  • icu_rolling_w_prime Float
  • icu_rolling_p_max Float
  • icu_rolling_ftp Integer
  • icu_rolling_ftp_delta Integer
  • icu_training_load Integer
  • icu_atl Float
  • icu_ctl Float
  • paired_event_id Integer
  • name String
  • description String
  • start_date String ~ ISO-8601 UTC timezone e.g. 2022-12-28T05:56:38Z
  • distance Float
  • icu_distance Float ~ Use this one for distance.
  • moving_time Integer
  • elapsed_time Integer
  • coasting_time Integer ~ Time spend moving at 1km/h or more while producing 10w or less of power
  • total_elevation_gain Float
  • timezone String ~ Java timezone IDs e.g. Africa/Johannesburg
  • trainer Boolean
  • commute Boolean
  • max_speed Float
  • average_speed Float
  • device_watts Boolean
  • has_heartrate Boolean
  • max_heartrate Integer
  • average_heartrate Integer
  • average_cadence Float
  • calories Integer
  • average_temp Float
  • min_temp Integer
  • max_temp Integer
  • avg_lr_balance Float
  • gap Float ~ Gradient adjusted pace
  • gap_model GapModel
  • use_elevation_correction Boolean
  • race Boolean
  • gear StravaGear
  • laps List<Activity.Lap>
  • perceived_exertion Float
  • device_name String
  • power_meter String
  • power_meter_serial String
  • power_meter_battery String
  • crank_length Float ~ In millimeters
  • external_id String ~ ID of the activity on the service it came from
  • file_sport_index int ~ For multisport files the index of this activity (0=first, 1=second etc.)
  • file_type String ~ Type of file: fit, tcx, gpx
  • icu_athlete_id String
  • created Date
  • icu_sync_date Date
  • analyzed Date
  • icu_ftp Integer
  • icu_w_prime Integer
  • threshold_pace Float
  • icu_hr_zones int ~ Max HR for each zone so last entry is athlete’s max HR
  • pace_zones float ~ Percentage of threshold pace for the top of each zone
  • lthr Integer
  • icu_resting_hr Integer
  • icu_weight Float
  • icu_power_zones int ~ Max watts for each zone as % of FTP with first entry Z1
  • icu_sweet_spot_min int ~ Sweet spot start as % of FTP (inclusive)
  • icu_sweet_spot_max int ~ Sweet spot end as % of FTP (inclusive)
  • icu_power_spike_threshold Integer
  • trimp Float
  • icu_warmup_time Integer
  • icu_cooldown_time Integer
  • icu_chat_id Integer
  • icu_ignore_hr Boolean
  • ignore_velocity Boolean
  • ignore_pace Boolean
  • ignore_parts List<Activity.Ignore>
  • icu_weighted_avg_watts Integer ~ Normalized watts
  • icu_training_load_data Integer
  • icu_intervals List<Interval>
  • icu_groups List<IntervalGroup>
  • interval_summary String
  • stream_types List<String> ~ These are the stored streams. Others e.g. fixed_watts are computed on the fly
  • has_segments boolean
  • power_field_names String ~ The names of fields from FIT file that could provide power data
  • power_field String ~ The name of the field providing power data for this activity
  • icu_zone_times List<ZoneTime> ~ Seconds in each power zone
  • icu_hr_zone_times int ~ Seconds in each heart rate zone
  • pace_zone_times int ~ Seconds in each pace zone
  • gap_zone_times int ~ Seconds in each pace zone using gradient adjusted pace
  • use_gap_zone_times Boolean
  • tiz_order ZoneOrder
  • polarization_index Float
  • icu_achievements List<IcuAchievement>
  • icu_intervals_edited Boolean
  • lock_intervals Boolean
  • icu_lap_count int
  • icu_joules Integer
  • icu_joules_above_ftp Integer
  • icu_max_wbal_depletion Integer
  • icu_recording_time Integer ~ Total time for the activity with recording gaps longer than 30s removed
  • icu_hrr HRRecovery
  • icu_sync_error String
  • icu_color String
  • icu_power_hr_z2 Float
  • icu_power_hr_z2_mins Integer
  • icu_cadence_z2 Integer
  • icu_rpe Integer
  • feel Integer
  • kg_lifted Float
  • decoupling Float
  • icu_median_time_delta Integer ~ Median seconds between data ticks
  • p30s_exponent Float
  • workout_shift_secs Integer ~ How much to adjust the start of the workout relative to the activity
  • strava_id String ~ For activities not from strava that replaced strava activities
  • lengths Integer ~ Number of lengths for pool swims
  • pool_length Float
  • compliance Float
  • coach_tick Integer
  • source Activity.Source
  • oauth_client_id Integer
  • oauth_client_name String
  • average_altitude Float
  • min_altitude Float
  • max_altitude Float
  • power_load Integer ~ Training load computed from power data (TSS)
  • hr_load Integer ~ Training load computed from heart rate data
  • pace_load Integer ~ Training load computed from pace data
  • hr_load_type HRLoadModel.Type
  • pace_load_type PaceTssCalc.Type
  • tags List<String>
  • attachments List<Attachment>
  • recording_stops List<Integer>
  • customFields Map<String, Object>
  • intensity Float ~ Use icu_intensity instead
  • deleted boolean
  • icu_training_load_edited Boolean
  • isNew boolean ~ Activity has been newly created or its file is being re-processed. This allows activity field scripts to
    transform fields read from FIT files once and not every time the activity is analyzed.
  • icu_average_watts Integer ~ Total joules of work / icu_recording_time
  • icu_efficiency_factor Float
  • icu_variability_index Float
  • icu_power_hr Float
  • icu_intensity Float
  • pace Float ~ In m/s. Uses moving time if available otherwise elapsed time.
  • session_rpe Integer
  • athlete_max_hr Integer
  • average_stride Float ~ Stride length in meters.

GapModel

  • NONE, STRAVA_RUN

StravaGear

Bike or shoes.

  • id String

Activity.Lap

  • start_index int
  • end_index int
  • name String

Activity.Ignore

  • start_index int
  • end_index int
  • power boolean
  • pace boolean
  • hr boolean

Interval

  • start_index int ~ First data point for this interval in the activity streams. Use this to index over stream data for an interval.
    Example: for (let i = interval.start_index; i < interval.end_index; i++) joules += watts[i]
  • distance Float
  • moving_time int
  • elapsed_time int
  • average_watts Integer
  • average_watts_alt Integer
  • average_watts_alt_acc Integer
  • min_watts Integer
  • max_watts Integer
  • average_watts_kg Float
  • max_watts_kg Float
  • intensity Integer
  • w5s_variability Float
  • weighted_average_watts Integer
  • training_load Float
  • joules Integer
  • joules_above_ftp Integer
  • decoupling Float
  • avg_lr_balance Float
  • average_dfa_a1 Float
  • average_respiration Float
  • average_epoc Float
  • wbal_start Integer
  • wbal_end Integer
  • zone Integer
  • zone_min_watts Integer
  • zone_max_watts Integer
  • average_speed Float
  • min_speed Float
  • max_speed Float
  • gap Float
  • average_heartrate Integer
  • min_heartrate Integer
  • max_heartrate Integer
  • average_cadence Float
  • min_cadence Integer
  • max_cadence Integer
  • average_torque Float
  • min_torque Float
  • max_torque Float
  • total_elevation_gain Float
  • min_altitude Float
  • max_altitude Float
  • average_gradient Float
  • average_smo2 Float
  • average_thb Float
  • average_smo2_2 Float
  • average_thb_2 Float
  • customFields Map<String, Object>
  • average_stride Float
  • id int
  • type Interval.Type
  • end_index int ~ Last data point for this interval in the activity streams (exclusive). Use this to index over stream data for an interval.
  • group_id String
  • segment_effort_ids List<Long>
  • start_time int ~ Start time in seconds relative to the start of the activity. Do not use this to loop over activity stream data, use
    start_index and end_index instead.
  • end_time int
  • label String

Interval.Type

  • RECOVERY, WORK

IntervalGroup

  • start_index int ~ First data point for this interval in the activity streams. Use this to index over stream data for an interval.
    Example: for (let i = interval.start_index; i < interval.end_index; i++) joules += watts[i]
  • distance Float
  • moving_time int
  • elapsed_time int
  • average_watts Integer
  • average_watts_alt Integer
  • average_watts_alt_acc Integer
  • min_watts Integer
  • max_watts Integer
  • average_watts_kg Float
  • max_watts_kg Float
  • intensity Integer
  • w5s_variability Float
  • weighted_average_watts Integer
  • training_load Float
  • joules Integer
  • joules_above_ftp Integer
  • decoupling Float
  • avg_lr_balance Float
  • average_dfa_a1 Float
  • average_respiration Float
  • average_epoc Float
  • wbal_start Integer
  • wbal_end Integer
  • zone Integer
  • zone_min_watts Integer
  • zone_max_watts Integer
  • average_speed Float
  • min_speed Float
  • max_speed Float
  • gap Float
  • average_heartrate Integer
  • min_heartrate Integer
  • max_heartrate Integer
  • average_cadence Float
  • min_cadence Integer
  • max_cadence Integer
  • average_torque Float
  • min_torque Float
  • max_torque Float
  • total_elevation_gain Float
  • min_altitude Float
  • max_altitude Float
  • average_gradient Float
  • average_smo2 Float
  • average_thb Float
  • average_smo2_2 Float
  • average_thb_2 Float
  • customFields Map<String, Object>
  • average_stride Float
  • id String
  • count int

ZoneTime

  • id String
  • secs int

ZoneOrder

  • POWER_HR_PACE, POWER_PACE_HR, HR_POWER_PACE, HR_PACE_POWER, PACE_POWER_HR, PACE_HR_POWER

IcuAchievement

IcuAchievement.Type

  • BEST_POWER, FTP_UP, LTHR_UP, BEST_PACE

DataCurvePt

  • start_index int
  • end_index int
  • secs int
  • value int

HRRecovery

A HR recovery interval.

  • start_index int
  • end_index int
  • start_time int
  • end_time int
  • start_bpm int
  • end_bpm int
  • average_watts Integer
  • hrr int

Activity.Source

  • STRAVA, UPLOAD, MANUAL, GARMIN_CONNECT, OAUTH_CLIENT, DROPBOX, POLAR, SUUNTO, COROS, WAHOO

HRLoadModel.Type

  • AVG_HR, HR_ZONES, HRSS

PaceTssCalc.Type

  • SWIM, RUN

Attachment

  • id String
  • filename String
  • mimetype String

ActivityJsData

This is the ‘icu’ object provided to scripts for custom activity charts and custom activity fields.

  • activity Activity ~ The activity being analysed
  • athlete Athlete
  • sportSettings SportSettings ~ For the sport of the activity
  • streams ActivityStreamSet ~ Power, HR and other traces
  • wellness Wellness ~ Weight, resting HR etc. on the day of the activity
  • fit JsFit ~ Messages from the fit file (only for activity fields and streams with ‘Processes fit file messages’ set)
  • fitSdk JsFitSDK ~ Misc methods for looking up names for fit file values etc.
  • powerCurve JsPowerCurve ~ Power duration curve
  • powerCurveFatigued0 JsPowerCurve ~ Power curve after sportSettings.after_kj0 kJ of work
  • powerCurveFatigued1 JsPowerCurve ~ Power curve after sportSettings.after_kj1 kJ of work
  • paceCurve JsPaceCurve
  • gapCurve JsPaceCurve ~ Gradient adjusted pace curve
  • hrCurve JsPaceCurve ~ Heart rate duration curve
  • bestPower JsDataCurveFactory ~ Athlete best power (MMP) to date including this activity
  • bestPace JsDataCurveFactory ~ Athlete best pace to date including this activity
  • bestGAP JsDataCurveFactory ~ Athlete best GAP to date including this activity
  • bestHR JsDataCurveFactory ~ Athlete best HR to date including this activity
  • bestPowerBefore JsDataCurveFactory ~ Athlete best power (MMP) to date before this activity
  • bestPaceBefore JsDataCurveFactory ~ Athlete best pace to date before this activity
  • bestGAPBefore JsDataCurveFactory ~ Athlete best GAP to date before this activity
  • bestHRBefore JsDataCurveFactory ~ Athlete best HR to date before this activity
  • stats JsStats ~ Utility methods to compute moving averages etc.

ActivityStreamSet

Set of activity streams (data traces) and related objects loaded/created on demand. Acts as a map returning the
data for the stream. You can do icu.streams.fixed_heartrate or icu.streams.fixed_watts to get the data for
the heart rate or power stream (or null if none). Types: time, watts, cadence, heartrate, distance, altitude, latlng,
velocity_smooth, moving, grade_smooth, temp, torque, fixed_watts, fixed_heartrate, left_right_balance,
left_pedal_smoothness, right_pedal_smoothness, left_torque_effectiveness, right_torque_effectiveness,
smo2, thb, smo2_2, thb_2, dfa_a1, epoc, hrv, ga_velocity, fixed_altitude, corrupt_time, core_temperature,
skin_temperature, stride_length, w_bal, respiration, tidal_volume, tidal_volume_min, watts_alt, watts_alt_acc,
bloodglucose, artifacts.

For latlng you need to do let latlng = icu.streams.get('latlng'); let lat = latlng.data; let lng = latlng.data2.

  • get(String type) ActivityStream ~ Returns null if stream does not exist.

ActivityStream

A value over time trace for an activity.

  • type String
  • name String
  • data Object ~ Integer, Float, Boolean, int (fixed_watts), short (hrv)
  • data2 Object ~ Float only for type latlng holding the longitude data (latitude is in data)
  • anomalies List<ActivityStream.Anomaly>

ActivityStream.Anomaly

Part of the stream was dodgy and the data was replaced.

  • start_index int
  • end_index int
  • value int
  • valueEnd Integer

Athlete

  • id String
  • name String
  • firstname String
  • lastname String
  • profile_medium String
  • measurement_preference String
  • weight_pref_lb Boolean
  • fahrenheit Boolean
  • wind_speed Athlete.WindSpeed
  • rain Athlete.Rain
  • weight Float
  • email String
  • sex String
  • city String
  • state String
  • country String
  • timezone String
  • locale String
  • bio String
  • website String
  • icu_date_of_birth String
  • icu_type_settings List<ActivityType.Settings>
  • icu_form_as_percent Boolean
  • icu_mmp_days Integer
  • icu_wellness_keys List<String>

Athlete.WindSpeed

  • MPS, KNOTS, KMH, MPH, BFT

Athlete.Rain

  • MM, INCHES

ActivityType.Settings

These are used to adjust training load from HR activities.

ActivityType

Keep in sync with ActivityTypes.js.

  • Ride, Run, Swim, WeightTraining, Hike, Walk, AlpineSki, BackcountrySki, Badminton, Canoeing, Crossfit, EBikeRide, EMountainBikeRide, Elliptical, Golf, GravelRide, Handcycle, HighIntensityIntervalTraining, Hockey, IceSkate, InlineSkate, Kayaking, Kitesurf, MountainBikeRide, NordicSki, OpenWaterSwim, Padel, Pilates, Pickleball, Racquetball, Rugby, RockClimbing, RollerSki, Rowing, Sail, Skateboard, Snowboard, Snowshoe, Soccer, Squash, StairStepper, StandUpPaddling, Surfing, TableTennis, Tennis, TrailRun, Transition, Velomobile, VirtualRide, VirtualRow, VirtualRun, WaterSport, Wheelchair, Windsurf, Workout, Yoga, Other

CustomItem

A custom chart, field etc.

  • id int
  • athlete_id String
  • type CustomItem.Type
  • visibility CustomItem.Visibility
  • name String
  • description String
  • image String
  • content Map<String, Object>
  • usage_count int
  • index Integer
  • hide_script Boolean
  • hidden_by_id String

CustomItem.Type

  • FITNESS_CHART, TRACE_CHART, INPUT_FIELD, ACTIVITY_FIELD, INTERVAL_FIELD, ACTIVITY_STREAM, ACTIVITY_CHART, ACTIVITY_HISTOGRAM, ACTIVITY_HEATMAP

CustomItem.Visibility

  • PRIVATE, FOLLOWERS, PUBLIC

JsDataCurveFactory

Factory and cache for power, hr, GAP or pace curves for an athlete with a given start date.

  • Use 42d, 84d etc. to get curve for given number of days
  • Use s0, s1 etc. for this season, last season and so on
  • Add -kj0 or -kj1 (e.g. 42d-kj0) to get fatigued curves (power only)

Example usage in a custom activity chart script:

let mmp42d = icu.bestPower['42d']
let best5mWatts = mmp42d.getWatts(5 * 60)

JsFit

Access to the messages read from the fit file. Acts as an array (all the messages in order) and as a map
where the keys are message names. Example: icu.fit.device_info returns an array of all the device_info messages.
For more info on the fit file format please visit FIT SDK site.

JsFitField

A field from a mesg in a fit file.

  • name String
  • units String
  • num int
  • numValues int
  • value Object ~ String, number or array.
  • valueName String ~ If the field is an enum then return name of the value if possible. Otherwise return it as a string or null
    if the value is null. Note that this does not work for some fields in which case ‘enumValueName’ in
    JsFitSDK can be used.
  • isAccumulated boolean
  • toString() String

JsFitMesg

A mesg from a fit file. Acts as an array of all the fields and developer fields in order and as a map (keys
are field names). Example: di.manufacturer?.value returns the value of the manufacturer field or null if not
present. Fields can also be looked up by number using f_ prefix e.g. m.f_136. Has a few other attributes:

  • _num ~ The fit number of this message
  • _name ~ The name of this message
  • _numFields ~ The number of non-developer fields (they are first)

JsFitSDK

Provides access to misc things from the FIT SDK.

  • enumValueName(String profileType, Number v) String ~ Returns the string name associated with a given enum value. If there is no such label, returns the string
    representation of the numerical value instead. Note that ‘valueName’ in JsFitField often
    works and is easier to use. The profileType values are:
    ENUM,
    SINT8,
    UINT8,
    SINT16,
    UINT16,
    SINT32,
    UINT32,
    STRING,
    FLOAT32,
    FLOAT64,
    UINT8Z,
    UINT16Z,
    UINT32Z,
    BYTE,
    SINT64,
    UINT64,
    UINT64Z,
    BOOL,
    FILE,
    MESG_NUM,
    CHECKSUM,
    FILE_FLAGS,
    MESG_COUNT,
    DATE_TIME,
    LOCAL_DATE_TIME,
    MESSAGE_INDEX,
    DEVICE_INDEX,
    GENDER,
    LANGUAGE,
    LANGUAGE_BITS_0,
    LANGUAGE_BITS_1,
    LANGUAGE_BITS_2,
    LANGUAGE_BITS_3,
    LANGUAGE_BITS_4,
    TIME_ZONE,
    DISPLAY_MEASURE,
    DISPLAY_HEART,
    DISPLAY_POWER,
    DISPLAY_POSITION,
    SWITCH,
    SPORT,
    SPORT_BITS_0,
    SPORT_BITS_1,
    SPORT_BITS_2,
    SPORT_BITS_3,
    SPORT_BITS_4,
    SPORT_BITS_5,
    SPORT_BITS_6,
    SUB_SPORT,
    SPORT_EVENT,
    ACTIVITY,
    INTENSITY,
    SESSION_TRIGGER,
    AUTOLAP_TRIGGER,
    LAP_TRIGGER,
    TIME_MODE,
    BACKLIGHT_MODE,
    DATE_MODE,
    BACKLIGHT_TIMEOUT,
    EVENT,
    EVENT_TYPE,
    TIMER_TRIGGER,
    FITNESS_EQUIPMENT_STATE,
    TONE,
    AUTOSCROLL,
    ACTIVITY_CLASS,
    HR_ZONE_CALC,
    PWR_ZONE_CALC,
    WKT_STEP_DURATION,
    WKT_STEP_TARGET,
    GOAL,
    GOAL_RECURRENCE,
    GOAL_SOURCE,
    SCHEDULE,
    COURSE_POINT,
    MANUFACTURER,
    GARMIN_PRODUCT,
    ANTPLUS_DEVICE_TYPE,
    ANT_NETWORK,
    WORKOUT_CAPABILITIES,
    BATTERY_STATUS,
    HR_TYPE,
    COURSE_CAPABILITIES,
    WEIGHT,
    WORKOUT_HR,
    WORKOUT_POWER,
    BP_STATUS,
    USER_LOCAL_ID,
    SWIM_STROKE,
    ACTIVITY_TYPE,
    ACTIVITY_SUBTYPE,
    ACTIVITY_LEVEL,
    SIDE,
    LEFT_RIGHT_BALANCE,
    LEFT_RIGHT_BALANCE_100,
    LENGTH_TYPE,
    DAY_OF_WEEK,
    CONNECTIVITY_CAPABILITIES,
    WEATHER_REPORT,
    WEATHER_STATUS,
    WEATHER_SEVERITY,
    WEATHER_SEVERE_TYPE,
    TIME_INTO_DAY,
    LOCALTIME_INTO_DAY,
    STROKE_TYPE,
    BODY_LOCATION,
    SEGMENT_LAP_STATUS,
    SEGMENT_LEADERBOARD_TYPE,
    SEGMENT_DELETE_STATUS,
    SEGMENT_SELECTION_TYPE,
    SOURCE_TYPE,
    LOCAL_DEVICE_TYPE,
    BLE_DEVICE_TYPE,
    ANT_CHANNEL_ID,
    DISPLAY_ORIENTATION,
    WORKOUT_EQUIPMENT,
    WATCHFACE_MODE,
    DIGITAL_WATCHFACE_LAYOUT,
    ANALOG_WATCHFACE_LAYOUT,
    RIDER_POSITION_TYPE,
    POWER_PHASE_TYPE,
    CAMERA_EVENT_TYPE,
    SENSOR_TYPE,
    BIKE_LIGHT_NETWORK_CONFIG_TYPE,
    COMM_TIMEOUT_TYPE,
    CAMERA_ORIENTATION_TYPE,
    ATTITUDE_STAGE,
    ATTITUDE_VALIDITY,
    AUTO_SYNC_FREQUENCY,
    EXD_LAYOUT,
    EXD_DISPLAY_TYPE,
    EXD_DATA_UNITS,
    EXD_QUALIFIERS,
    EXD_DESCRIPTORS,
    AUTO_ACTIVITY_DETECT,
    SUPPORTED_EXD_SCREEN_LAYOUTS,
    FIT_BASE_TYPE,
    TURN_TYPE,
    BIKE_LIGHT_BEAM_ANGLE_MODE,
    FIT_BASE_UNIT,
    SET_TYPE,
    MAX_MET_CATEGORY,
    EXERCISE_CATEGORY,
    BENCH_PRESS_EXERCISE_NAME,
    CALF_RAISE_EXERCISE_NAME,
    CARDIO_EXERCISE_NAME,
    CARRY_EXERCISE_NAME,
    CHOP_EXERCISE_NAME,
    CORE_EXERCISE_NAME,
    CRUNCH_EXERCISE_NAME,
    CURL_EXERCISE_NAME,
    DEADLIFT_EXERCISE_NAME,
    FLYE_EXERCISE_NAME,
    HIP_RAISE_EXERCISE_NAME,
    HIP_STABILITY_EXERCISE_NAME,
    HIP_SWING_EXERCISE_NAME,
    HYPEREXTENSION_EXERCISE_NAME,
    LATERAL_RAISE_EXERCISE_NAME,
    LEG_CURL_EXERCISE_NAME,
    LEG_RAISE_EXERCISE_NAME,
    LUNGE_EXERCISE_NAME,
    OLYMPIC_LIFT_EXERCISE_NAME,
    PLANK_EXERCISE_NAME,
    PLYO_EXERCISE_NAME,
    PULL_UP_EXERCISE_NAME,
    PUSH_UP_EXERCISE_NAME,
    ROW_EXERCISE_NAME,
    SHOULDER_PRESS_EXERCISE_NAME,
    SHOULDER_STABILITY_EXERCISE_NAME,
    SHRUG_EXERCISE_NAME,
    SIT_UP_EXERCISE_NAME,
    SQUAT_EXERCISE_NAME,
    TOTAL_BODY_EXERCISE_NAME,
    TRICEPS_EXTENSION_EXERCISE_NAME,
    WARM_UP_EXERCISE_NAME,
    RUN_EXERCISE_NAME,
    WATER_TYPE,
    TISSUE_MODEL_TYPE,
    DIVE_GAS_STATUS,
    DIVE_ALERT,
    DIVE_ALARM_TYPE,
    DIVE_BACKLIGHT_MODE,
    SLEEP_LEVEL,
    SPO2_MEASUREMENT_TYPE,
    CCR_SETPOINT_SWITCH_MODE,
    DIVE_GAS_MODE,
    FAVERO_PRODUCT,
    SPLIT_TYPE,
    CLIMB_PRO_EVENT,
    GAS_CONSUMPTION_RATE_TYPE,
    TAP_SENSITIVITY,
    RADAR_THREAT_LEVEL_TYPE,
    MAX_MET_SPEED_SOURCE,
    MAX_MET_HEART_RATE_SOURCE,
    HRV_STATUS,
    NO_FLY_TIME_MODE

JsHRCurve

A heart rate duration curve.

  • secs int ~ Time points. Note that not all seconds are included. The curve gets sparse as time goes out.
  • bpm int ~ HR for corresponding entry in secs.
  • start_index int ~ Where corresponding point starts in the activity
  • end_index int ~ Where corresponding point ends in the activity (exclusive)
  • indexOf(int seconds) int ~ What is the index of the point on the curve that has a duration of at least seconds? Returns -1 if the curve
    is not that long.
  • getBpm(int seconds) Integer

JsPaceCurve

A pace duration curve.

  • isGap boolean ~ Is this gradient adjusted pace?
  • distance float ~ Distance points. Note that not all distances are included. The curve gets sparse as time goes out.
  • secs int ~ Time to cover the matching distance.
  • start_index int ~ Where corresponding point starts in the activity
  • end_index int ~ Where corresponding point ends in the activity (exclusive)
  • indexOf(float distance) int ~ What is the index of the point on the curve that has a distance of at least distance? Returns -1 if the curve
    is not that long.
  • getSpeed(float distance) Float ~ Returns speed in meters/second or null if curve not that long. Note that the distance might be more than the
    distance parameter.

JsPowerCurve

A power duration curve.

  • secs int ~ Time points. Note that not all seconds are included. The curve gets sparse as time goes out.
  • watts int ~ Power for corresponding entry in secs.
  • watts_per_kg float ~ Power/weight for corresponding entry in secs.
  • start_index int ~ Where corresponding point starts in the activity
  • end_index int ~ Where corresponding point ends in the activity (exclusive)
  • after_kj int ~ If the curve is fatigued then this is the amount of work done before the curve.
  • vo2max_5m Float ~ VO2max calculated from 5m watts/kg
  • compound_score_5m Float ~ Compound score calculated from 5m watts/kg
  • indexOf(int seconds) int ~ What is the index of the point on the curve that has a duration of at least seconds? Returns -1 if the curve
    is not that long.
  • getWatts(int seconds) Integer
  • getWattsPerKg(int seconds) Float

JsStats

  • calcMovingAvg(Float series, int points) float ~ Calculate a moving average for the series that is points wide. Nulls are treated as zero.
  • calcCenteredMovingAvg(Float series, int points) float ~ Calculate a moving average for the series that is points wide. Nulls are treated as zero.

JsStreamData

Data for a custom activity stream. There is one entry for each record message used from the fit file. The time
of each entry is the timestamp of the corresponding record less the startTimestamp of first record used i.e.
seconds since the start of the activity. Acts as an array but setAt(timestamp, value) is likely the easiest
way to fill it with data.

  • startTimestamp int ~ Start of the activity stream in seconds since UTC 00:00 Dec 31 1989
  • duration int ~ Duration of the activity in seconds
  • time List<Integer> ~ The seconds trace (first entry is 0) since the start of the activity
  • setAt(int timestamp, Number value) void ~ Set the value at the closest position on or after timestamp. If timestamp is before the start of the stream or
    after the end then nothing is done. The timestamp parameter is seconds since UTC 00:00 Dec 31 1989 which is
    the standard way timestamps are stored in fit files.

SportSettings

FTP, training zones etc. for some sports.

  • id int
  • athlete_id String
  • types ActivityType[]
  • warmup_time Integer
  • cooldown_time Integer
  • ftp Integer
  • indoor_ftp Integer
  • w_prime Integer
  • power_zones int
  • sweet_spot_min Integer
  • sweet_spot_max Integer
  • power_spike_threshold Integer
  • power_zone_names String
  • ftp_est_min_secs Integer
  • use_laps_for_power_intervals Boolean
  • keep_all_laps_for_power_intervals Boolean
  • after_kj0 Integer
  • after_kj1 Integer
  • power_field String
  • lthr Integer
  • max_hr Integer
  • hr_zones int
  • hr_zone_names String
  • hr_load_type HRLoadModel.Type
  • hrrc_min_percent Float
  • threshold_pace Float
  • pace_units PaceUnits
  • pace_zones float
  • pace_zone_names String
  • pace_load_type PaceTssCalc.Type
  • gap_model GapModel
  • elevation_correction SportSettings.ElevationCorrection
  • use_gap_zone_times Boolean
  • best_effort_distances float
  • pace_curve_start Float
  • load_order ZoneOrder ~ Priority for calculating training load
  • tiz_order ZoneOrder ~ Priority for calculating time in zones
  • workout_order ZoneOrder ~ Priority for executing workouts
  • interval_display ZoneOrder ~ Priority for displaying intervals
  • default_gear_id String
  • default_indoor_gear_id String
  • extract_workouts Boolean ~ Extract workouts from activity files if possible
  • show_pauses Integer
  • ignore_velocity Boolean

PaceUnits

Units for threshold pace.

  • SECS_100M, SECS_100Y, MINS_KM, MINS_MILE, SECS_500M

SportSettings.ElevationCorrection

  • NO, AUTO, YES

Wellness

Daily values for an athlete. Read and write custom fields from JavaScript using wellness.[field code].

  • id String
  • ctl Float
  • atl Float
  • rampRate Float
  • ctlLoad Float
  • atlLoad Float
  • sportInfo List<WellnessFitness.SportInfo>
  • weight Float
  • restingHR Integer
  • hrv Float ~ rMSSD
  • hrvSDNN Float
  • menstrualPhase MenstrualPhase
  • menstrualPhasePredicted MenstrualPhase
  • kcalConsumed Integer
  • sleepSecs Integer
  • sleepScore Float
  • sleepQuality Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • avgSleepingHR Float
  • soreness Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • fatigue Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • stress Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • mood Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • motivation Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • injury Integer ~ Injured(4), Poor(3), Niggle(2), Excellent(1)
  • spO2 Float ~ 0-100%
  • systolic Integer ~ blood pressure mmHg
  • diastolic Integer
  • hydration Integer ~ Well Hydrated (1), Hydrated(2), Dehydrated(3), Very Dehydrated(4)
  • hydrationVolume Float ~ litres consumed
  • readiness Float
  • baevskySI Float
  • bloodGlucose Float ~ mmol/L
  • lactate Float ~ mmol/L
  • bodyFat Float ~ %
  • abdomen Float ~ cm
  • vo2max Float ~ ml/kg/min
  • comments String
  • steps Integer ~ rMSSD
  • respiration Float
  • locked Boolean ~ Updates via API and integrations ignored
  • customFields Map<String, Object>
  • tempWeight boolean ~ Indicates value was updated from athlete settings and is not authoritative
  • tempRestingHR boolean

WellnessFitness.SportInfo

MenstrualPhase

  • PERIOD, FOLLICULAR, OVULATING, LUTEAL, NONE
5 Likes

What are the names in the ActivityStreams? Maybe I am not asking the right question, but I if I wanted to compute a metric based on say how the activity hr varies, how would I pull the HR time response?

I added the types to the ActivityStream entry above. You need to get the fixed_heartrate stream and maybe also time (if you are concerned about activities with multiple seconds between ticks). I am going to add some support for interpolating these streams to 1 second per tick soon.

Hi David. I just want to confirm which is the correct param for power zone times. I can see hr zone times and pace zone times, so is icu_zone_times the one for power?

Thanks

John

Yes that is correct. I am going to add a lot more comments to those records.

The names and so on are a legacy thing from when Intervals.icu only did Strava and cycling. The icu_ prefix was to avoid conflicts with Strava API names. It’s “icu_zone_times” instead of “power_zone_times” because Intervals.icu used to only calculate power zones.

2 Likes

Great thanks. You should see some of the original param names in the backend EnDuRA code :joy:

2 Likes

I have just added a bunch of missing fields for Activity and Interval. My code to generate this information was buggy.

Hi @david
Is it possible to add in Activity:
activity.strokes

This value is directly in swimming fit file in line: “total_strokes”:


it’s needed for SWOLF calculation of swimming activity.
Thank you in advance

You can calculate the number of strokes from the average cadence for the interval or activity and the moving time. The cadence is strokes per minute. So divide that by 60 to get strokes per second.

I did a bit of googling and it seems SWOLF is calculated per 25m (strokes + seconds). So for the whole activity the SWOLF calculation looks like this:

{
let strokesPerSec = activity.average_cadence / 60
let strokes = activity.moving_time * strokesPerSec
let swolf = (strokes + activity.moving_time) * 25 / activity.icu_distance
swolf
}

I have added public custom activity and interval SWOLF fields using this calculation.

2 Likes

Hi,

Is there a way to get values from the MMP (Mean Maximal Power) that is built on last 42/84 days before an activity inside an activity script ?

Not at the moment. That could be done with some effort. What are you trying to compute?

I’m trying to draw two curves on the power page of activities:

  • The W’ plot presented by Veloclinic using the CP/FTP value and W’ of the activity with the MMP curve of the last 42 days preceding each activity superimposed on the MMP curve of the activity (The graph in question was discussed in another topic on the forum and is detailed here : Veloclinic Plot (W' plot) - veloclinic).

  • I would also like to plot the histogram of the time spent during the activity not for each power value presented on the x-axis but for each duration on the MMP curve computed over the duration set for the workouts.

1 Like

That sounds good! I have added experimental support for this to the icu object available to custom activity charts. I will document it properly when it is stable. So let me know if this works. Here’s is an example script:

{
  let text = "Best 5m power " + icu.powerCurve.getWatts(300) + "w"
  let pc42d = icu.bestPower['42d']
  let before42d = icu.bestPowerBefore['42d']
  text += ", prev 42d " + before42d.getWatts(300) + "w (including this activity " + pc42d.getWatts(300) + "w)"
  console.log(text)
  chart = { data: [], layout: { title: { text } } }
}

  • icu.bestPower and icu.bestPowerBefore give MMP including and excluding this activity
  • Use 42d, 84d etc. to get curve for given number of days
  • Use s0, s1 etc. for this season, last season and so on
  • Add -kj0 or -kj1 (e.g. 42d-kj0) to get fatigued curves

There are also bestPace, bestGAP, bestHR with corresponding before variants for pace, gradient adjusted pace and heart rate.

5 Likes

Woaw ! Thank you @david for your responsiveness.

I’ve created the W’ trace (veloclinic trace) in the power activity page (public chart). Everything works as expected. There’s just something that should be a point of attention in relation to the additions you’ve just made, when I use

icu.bestPower[‘s0’]

And for other long periods (‘365d’, ‘s1’, etc), I get the following error in the script

Memory limit exceeded

2 Likes

Thank you both @david @Hugo_Joudrier !

1 Like

I just updated the docs including the ActivityJsData ‘icu’ object that I somehow missed:

This is the ‘icu’ object provided to scripts for custom activity charts and custom activity fields.

Activity

A completed activity (Ride, Run etc.). Read and write custom fields from JavaScript using activity.[field code].
All fields are metric. Times are in seconds. Speeds are in meters / sec. Temperatures are in degrees C.

  • id String
  • start_date_local String
  • type String
  • icu_ignore_time Boolean
  • icu_pm_cp Integer
  • icu_pm_w_prime Integer
  • icu_pm_p_max Integer
  • icu_pm_ftp Integer
  • icu_pm_ftp_secs Integer
  • icu_pm_ftp_watts Integer
  • icu_ignore_power Boolean
  • icu_rolling_cp Float
  • icu_rolling_w_prime Float
  • icu_rolling_p_max Float
  • icu_rolling_ftp Integer
  • icu_rolling_ftp_delta Integer
  • icu_training_load Integer
  • icu_atl Float
  • icu_ctl Float
  • paired_event_id Integer
  • name String
  • description String
  • start_date String ~ ISO-8601 UTC timezone e.g. 2022-12-28T05:56:38Z
  • distance Float
  • icu_distance Float ~ Use this one for distance.
  • moving_time Integer
  • elapsed_time Integer
  • coasting_time Integer ~ Time spend moving at 1km/h or more while producing 10w or less of power
  • total_elevation_gain Float
  • timezone String ~ Java timezone IDs e.g. Africa/Johannesburg
  • trainer Boolean
  • commute Boolean
  • max_speed Float
  • average_speed Float
  • device_watts Boolean
  • has_heartrate Boolean
  • max_heartrate Integer
  • average_heartrate Integer
  • average_cadence Float
  • calories Integer
  • average_temp Float
  • min_temp Integer
  • max_temp Integer
  • avg_lr_balance Float
  • gap Float ~ Gradient adjusted pace
  • gap_model GapModel
  • use_elevation_correction Boolean
  • race Boolean
  • gear StravaGear
  • laps List<Activity.Lap>
  • perceived_exertion Float
  • device_name String
  • power_meter String
  • power_meter_serial String
  • power_meter_battery String
  • crank_length Float ~ In millimeters
  • external_id String ~ ID of the activity on the service it came from
  • file_sport_index int ~ For multisport files the index of this activity (0=first, 1=second etc.)
  • file_type String ~ Type of file: fit, tcx, gpx
  • icu_athlete_id String
  • created Date
  • icu_sync_date Date
  • analyzed Date
  • icu_ftp Integer
  • icu_w_prime Integer
  • threshold_pace Float
  • icu_hr_zones int[] ~ Max HR for each zone so last entry is athlete’s max HR
  • pace_zones float[] ~ Percentage of threshold pace for the top of each zone
  • lthr Integer
  • icu_resting_hr Integer
  • icu_weight Float
  • icu_power_zones int[] ~ Max watts for each zone as % of FTP with first entry Z1
  • icu_sweet_spot_min int ~ Sweet spot start as % of FTP (inclusive)
  • icu_sweet_spot_max int ~ Sweet spot end as % of FTP (inclusive)
  • icu_power_spike_threshold Integer
  • trimp Float
  • icu_warmup_time Integer
  • icu_cooldown_time Integer
  • icu_chat_id Integer
  • icu_ignore_hr Boolean
  • ignore_velocity Boolean
  • ignore_pace Boolean
  • icu_weighted_avg_watts Integer ~ Normalized watts
  • icu_training_load_data Integer
  • icu_intervals List<Interval>
  • icu_groups List<IntervalGroup>
  • interval_summary String[]
  • stream_types List<String> ~ These are the stored streams. Others e.g. fixed_watts are computed on the fly
  • has_segments boolean
  • power_field_names String[] ~ The names of fields from FIT file that could provide power data
  • power_field String ~ The name of the field providing power data for this activity
  • icu_zone_times List<ZoneTime> ~ Seconds in each power zone
  • icu_hr_zone_times int[] ~ Seconds in each heart rate zone
  • pace_zone_times int[] ~ Seconds in each pace zone
  • gap_zone_times int[] ~ Seconds in each pace zone using gradient adjusted pace
  • use_gap_zone_times Boolean
  • tiz_order ZoneOrder
  • icu_achievements List<IcuAchievement>
  • icu_intervals_edited Boolean
  • lock_intervals Boolean
  • icu_lap_count int
  • icu_joules Integer
  • icu_joules_above_ftp Integer
  • icu_max_wbal_depletion Integer
  • icu_recording_time Integer ~ Total time for the activity with recording gaps longer than 30s removed
  • icu_hrr HRRecovery
  • icu_sync_error String
  • icu_color String
  • icu_power_hr_z2 Float
  • icu_power_hr_z2_mins Integer
  • icu_cadence_z2 Integer
  • icu_rpe Integer
  • feel Integer
  • kg_lifted Float
  • decoupling Float
  • icu_median_time_delta Integer ~ Median seconds between data ticks
  • p30s_exponent Float
  • workout_shift_secs Integer ~ How much to adjust the start of the workout relative to the activity
  • strava_id String ~ For activities not from strava that replaced strava activities
  • lengths Integer ~ Number of lengths for pool swims
  • pool_length Float
  • compliance Float
  • source Activity.Source
  • oauth_client_id Integer
  • oauth_client_name String
  • power_load Integer ~ Training load computed from power data (TSS)
  • hr_load Integer ~ Training load computed from heart rate data
  • pace_load Integer ~ Training load computed from pace data
  • hr_load_type HRLoadModel.Type
  • pace_load_type PaceTssCalc.Type
  • tags List<String>
  • recording_stops List<Integer>
  • customFields Map<String, Object>
  • intensity Float ~ Use icu_intensity instead
  • deleted boolean
  • icu_training_load_edited Boolean
  • isNew boolean ~ Activity has been newly created or its file is being re-processed. This allows activity field scripts to
    transform fields read from FIT files once and not every time the activity is analyzed.
  • icu_average_watts Integer ~ Total joules of work / icu_recording_time
  • icu_efficiency_factor Float
  • icu_variability_index Float
  • icu_power_hr Float
  • icu_intensity Float
  • pace Float ~ In m/s. Uses moving time if available otherwise elapsed time.
  • session_rpe Integer
  • athlete_max_hr Integer
  • average_stride Float ~ Stride length in meters.

GapModel

  • NONE, STRAVA_RUN

StravaGear

Bike or shoes.

  • id String

Activity.Lap

  • start_index int
  • end_index int
  • name String

Interval

  • start_index int ~ First data point for this interval in the activity streams. Use this to index over stream data for an interval.
    Example: for (let i = interval.start_index; i < interval.end_index; i++) joules += watts[i]
  • distance Float
  • moving_time int
  • elapsed_time int
  • average_watts Integer
  • average_watts_alt Integer
  • average_watts_alt_acc Integer
  • min_watts Integer
  • max_watts Integer
  • average_watts_kg Float
  • max_watts_kg Float
  • intensity Integer
  • w5s_variability Float
  • weighted_average_watts Integer
  • training_load Float
  • joules Integer
  • joules_above_ftp Integer
  • decoupling Float
  • avg_lr_balance Float
  • average_dfa_a1 Float
  • average_respiration Float
  • average_epoc Float
  • wbal_start Integer
  • wbal_end Integer
  • zone Integer
  • zone_min_watts Integer
  • zone_max_watts Integer
  • average_speed Float
  • min_speed Float
  • max_speed Float
  • gap Float
  • average_heartrate Integer
  • min_heartrate Integer
  • max_heartrate Integer
  • average_cadence Float
  • min_cadence Integer
  • max_cadence Integer
  • average_torque Float
  • min_torque Float
  • max_torque Float
  • total_elevation_gain Float
  • min_altitude Float
  • max_altitude Float
  • average_gradient Float
  • average_smo2 Float
  • average_thb Float
  • average_smo2_2 Float
  • average_thb_2 Float
  • customFields Map<String, Object>
  • average_stride Float
  • id int
  • type Interval.Type
  • end_index int ~ Last data point for this interval in the activity streams (exclusive). Use this to index over stream data for an interval.
  • group_id String
  • segment_effort_ids List<Long>
  • start_time int ~ Start time in seconds relative to the start of the activity. Do not use this to loop over activity stream data, use
    start_index and end_index instead.
  • end_time int
  • label String

Interval.Type

  • RECOVERY, WORK

IntervalGroup

  • start_index int ~ First data point for this interval in the activity streams. Use this to index over stream data for an interval.
    Example: for (let i = interval.start_index; i < interval.end_index; i++) joules += watts[i]
  • distance Float
  • moving_time int
  • elapsed_time int
  • average_watts Integer
  • average_watts_alt Integer
  • average_watts_alt_acc Integer
  • min_watts Integer
  • max_watts Integer
  • average_watts_kg Float
  • max_watts_kg Float
  • intensity Integer
  • w5s_variability Float
  • weighted_average_watts Integer
  • training_load Float
  • joules Integer
  • joules_above_ftp Integer
  • decoupling Float
  • avg_lr_balance Float
  • average_dfa_a1 Float
  • average_respiration Float
  • average_epoc Float
  • wbal_start Integer
  • wbal_end Integer
  • zone Integer
  • zone_min_watts Integer
  • zone_max_watts Integer
  • average_speed Float
  • min_speed Float
  • max_speed Float
  • gap Float
  • average_heartrate Integer
  • min_heartrate Integer
  • max_heartrate Integer
  • average_cadence Float
  • min_cadence Integer
  • max_cadence Integer
  • average_torque Float
  • min_torque Float
  • max_torque Float
  • total_elevation_gain Float
  • min_altitude Float
  • max_altitude Float
  • average_gradient Float
  • average_smo2 Float
  • average_thb Float
  • average_smo2_2 Float
  • average_thb_2 Float
  • customFields Map<String, Object>
  • average_stride Float
  • id String
  • count int

ZoneTime

  • id String
  • secs int

ZoneOrder

  • POWER_HR_PACE, POWER_PACE_HR, HR_POWER_PACE, HR_PACE_POWER, PACE_POWER_HR, PACE_HR_POWER

IcuAchievement

IcuAchievement.Type

  • BEST_POWER, FTP_UP, LTHR_UP, BEST_PACE

DataCurvePt

  • start_index int
  • end_index int
  • secs int
  • value int

HRRecovery

A HR recovery interval.

  • start_index int
  • end_index int
  • start_time int
  • end_time int
  • start_bpm int
  • end_bpm int
  • average_watts Integer
  • hrr int

Activity.Source

  • STRAVA, UPLOAD, MANUAL, GARMIN_CONNECT, OAUTH_CLIENT, DROPBOX, POLAR, SUUNTO, COROS, WAHOO

HRLoadModel.Type

  • AVG_HR, HR_ZONES, HRSS

PaceTssCalc.Type

  • SWIM, RUN

ActivityJsData

This is the ‘icu’ object provided to scripts for custom activity charts and custom activity fields.

  • activity Activity ~ The activity being analysed
  • athlete Athlete
  • sportSettings SportSettings ~ For the sport of the activity
  • streams ActivityStreamSet ~ Power, HR and other traces
  • wellness Wellness ~ Weight, resting HR etc. on the day of the activity
  • fit JsFit ~ Messages from the fit file (only for activity fields and streams with ‘Processes fit file messages’ set)
  • fitSdk JsFitSDK ~ Misc methods for looking up names for fit file values etc.
  • powerCurve JsPowerCurve ~ Power duration curve
  • powerCurveFatigued0 JsPowerCurve ~ Power curve after sportSettings.after_kj0 kJ of work
  • powerCurveFatigued1 JsPowerCurve ~ Power curve after sportSettings.after_kj1 kJ of work
  • paceCurve JsPaceCurve
  • gapCurve JsPaceCurve ~ Gradient adjusted pace curve
  • hrCurve JsPaceCurve ~ Heart rate duration curve
  • bestPower JsDataCurveFactory ~ Athlete best power (MMP) to date including this activity
  • bestPace JsDataCurveFactory ~ Athlete best pace to date including this activity
  • bestGAP JsDataCurveFactory ~ Athlete best GAP to date including this activity
  • bestHR JsDataCurveFactory ~ Athlete best HR to date including this activity
  • bestPowerBefore JsDataCurveFactory ~ Athlete best power (MMP) to date before this activity
  • bestPaceBefore JsDataCurveFactory ~ Athlete best pace to date before this activity
  • bestGAPBefore JsDataCurveFactory ~ Athlete best GAP to date before this activity
  • bestHRBefore JsDataCurveFactory ~ Athlete best HR to date before this activity

ActivityStreamSet

Set of activity streams (data traces) and related objects loaded/created on demand. Acts as a map returning the
data for the stream. You can do icu.streams.fixed_heartrate or icu.streams.fixed_watts to get the data for
the heart rate or power stream (or null if none). Types: time, watts, cadence, heartrate, distance, altitude, latlng,
velocity_smooth, moving, grade_smooth, temp, torque, fixed_watts, fixed_heartrate, left_right_balance,
left_pedal_smoothness, right_pedal_smoothness, left_torque_effectiveness, right_torque_effectiveness,
smo2, thb, smo2_2, thb_2, dfa_a1, epoc, hrv, ga_velocity, fixed_altitude, corrupt_time, core_temperature,
skin_temperature, stride_length, w_bal, respiration, tidal_volume, tidal_volume_min, watts_alt, watts_alt_acc,
bloodglucose, artifacts.

For latlng you need to do let latlng = icu.streams.get('latlng'); let lat = latlng.data; let lng = latlng.data2.

  • get(String type) ActivityStream ~ Returns null if stream does not exist.

ActivityStream

A value over time trace for an activity.

  • type String
  • name String
  • data Object ~ Integer[], Float[], Boolean[], int[] (fixed_watts), short[][] (hrv)
  • data2 Object ~ Float[] only for type latlng holding the longitude data (latitude is in data)
  • anomalies List<ActivityStream.Anomaly>

ActivityStream.Anomaly

Part of the stream was dodgy and the data was replaced.

  • start_index int
  • end_index int
  • value int
  • valueEnd Integer

Athlete

  • id String
  • name String
  • firstname String
  • lastname String
  • profile_medium String
  • measurement_preference String
  • weight_pref_lb Boolean
  • fahrenheit Boolean
  • wind_speed Athlete.WindSpeed
  • rain Athlete.Rain
  • weight Float
  • email String
  • sex String
  • city String
  • state String
  • country String
  • timezone String
  • locale String
  • bio String
  • website String
  • icu_date_of_birth String
  • icu_type_settings List<ActivityType.Settings>
  • icu_form_as_percent Boolean
  • icu_mmp_days Integer
  • icu_wellness_keys List<String>

Athlete.WindSpeed

  • MPS, KNOTS, KMH, MPH, BFT

Athlete.Rain

  • MM, INCHES

ActivityType.Settings

These are used to adjust training load from HR activities.

ActivityType

Keep in sync with ActivityTypes.js.

  • Ride, Run, Swim, WeightTraining, Hike, Walk, AlpineSki, BackcountrySki, Badminton, Canoeing, Crossfit, EBikeRide, EMountainBikeRide, Elliptical, Golf, GravelRide, Handcycle, HighIntensityIntervalTraining, IceSkate, InlineSkate, Kayaking, Kitesurf, MountainBikeRide, NordicSki, OpenWaterSwim, Padel, Pilates, Pickleball, Racquetball, Rugby, RockClimbing, RollerSki, Rowing, Sail, Skateboard, Snowboard, Snowshoe, Soccer, Squash, StairStepper, StandUpPaddling, Surfing, TableTennis, Tennis, TrailRun, Transition, Velomobile, VirtualRide, VirtualRow, VirtualRun, WaterSport, Wheelchair, Windsurf, Workout, Yoga, Other

CustomItem

A custom chart, field etc.

  • id int
  • athlete_id String
  • type CustomItem.Type
  • visibility CustomItem.Visibility
  • name String
  • description String
  • image String
  • content Map<String, Object>
  • usage_count int
  • index Integer

CustomItem.Type

  • FITNESS_CHART, TRACE_CHART, INPUT_FIELD, ACTIVITY_FIELD, INTERVAL_FIELD, ACTIVITY_STREAM, ACTIVITY_CHART

CustomItem.Visibility

  • PRIVATE, FOLLOWERS, PUBLIC

JsDataCurveFactory

Factory and cache for power, hr, GAP or pace curves for an athlete with a given start date.

  • Use 42d, 84d etc. to get curve for given number of days
  • Use s0, s1 etc. for this season, last season and so on
  • Add -kj0 or -kj1 (e.g. 42d-kj0) to get fatigued curves (power only)

Example usage in a custom activity chart script:

let mmp42d = icu.bestPower['42d']
let best5mWatts = mmp42d.getWatts(5 * 60)

JsFit

Access to the messages read from the fit file. Acts as an array (all the messages in order) and as a map
where the keys are message names. Example: icu.fit.device_info returns an array of all the device_info messages.
For more info on the fit file format please visit FIT SDK site.

JsFitField

A field from a mesg in a fit file.

  • name String
  • units String
  • num int
  • numValues int
  • value Object ~ String, number or array.
  • valueName String ~ If the field is an enum then return name of the value if possible. Otherwise return it as a string or null
    if the value is null. Note that this does not work for some fields in which case ‘enumValueName’ in
    JsFitSDK can be used.
  • isAccumulated boolean
  • toString() String

JsFitMesg

A mesg from a fit file. Acts as an array of all the fields and developer fields in order and as a map (keys
are field names). Example: di.manufacturer?.value returns the value of the manufacturer field or null if not
present. Has a few other attributes:

  • _num ~ The fit number of this message
  • _name ~ The name of this message
  • _numFields ~ The number of non-developer fields (they are first)

JsFitSDK

Provides access to misc things from the FIT SDK.

  • enumValueName(String profileType, Number v) String ~ Returns the string name associated with a given enum value. If there is no such label, returns the string
    representation of the numerical value instead. Note that ‘valueName’ in JsFitField often
    works and is easier to use. The profileType values are:
    ENUM,
    SINT8,
    UINT8,
    SINT16,
    UINT16,
    SINT32,
    UINT32,
    STRING,
    FLOAT32,
    FLOAT64,
    UINT8Z,
    UINT16Z,
    UINT32Z,
    BYTE,
    SINT64,
    UINT64,
    UINT64Z,
    BOOL,
    FILE,
    MESG_NUM,
    CHECKSUM,
    FILE_FLAGS,
    MESG_COUNT,
    DATE_TIME,
    LOCAL_DATE_TIME,
    MESSAGE_INDEX,
    DEVICE_INDEX,
    GENDER,
    LANGUAGE,
    LANGUAGE_BITS_0,
    LANGUAGE_BITS_1,
    LANGUAGE_BITS_2,
    LANGUAGE_BITS_3,
    LANGUAGE_BITS_4,
    TIME_ZONE,
    DISPLAY_MEASURE,
    DISPLAY_HEART,
    DISPLAY_POWER,
    DISPLAY_POSITION,
    SWITCH,
    SPORT,
    SPORT_BITS_0,
    SPORT_BITS_1,
    SPORT_BITS_2,
    SPORT_BITS_3,
    SPORT_BITS_4,
    SPORT_BITS_5,
    SPORT_BITS_6,
    SUB_SPORT,
    SPORT_EVENT,
    ACTIVITY,
    INTENSITY,
    SESSION_TRIGGER,
    AUTOLAP_TRIGGER,
    LAP_TRIGGER,
    TIME_MODE,
    BACKLIGHT_MODE,
    DATE_MODE,
    BACKLIGHT_TIMEOUT,
    EVENT,
    EVENT_TYPE,
    TIMER_TRIGGER,
    FITNESS_EQUIPMENT_STATE,
    TONE,
    AUTOSCROLL,
    ACTIVITY_CLASS,
    HR_ZONE_CALC,
    PWR_ZONE_CALC,
    WKT_STEP_DURATION,
    WKT_STEP_TARGET,
    GOAL,
    GOAL_RECURRENCE,
    GOAL_SOURCE,
    SCHEDULE,
    COURSE_POINT,
    MANUFACTURER,
    GARMIN_PRODUCT,
    ANTPLUS_DEVICE_TYPE,
    ANT_NETWORK,
    WORKOUT_CAPABILITIES,
    BATTERY_STATUS,
    HR_TYPE,
    COURSE_CAPABILITIES,
    WEIGHT,
    WORKOUT_HR,
    WORKOUT_POWER,
    BP_STATUS,
    USER_LOCAL_ID,
    SWIM_STROKE,
    ACTIVITY_TYPE,
    ACTIVITY_SUBTYPE,
    ACTIVITY_LEVEL,
    SIDE,
    LEFT_RIGHT_BALANCE,
    LEFT_RIGHT_BALANCE_100,
    LENGTH_TYPE,
    DAY_OF_WEEK,
    CONNECTIVITY_CAPABILITIES,
    WEATHER_REPORT,
    WEATHER_STATUS,
    WEATHER_SEVERITY,
    WEATHER_SEVERE_TYPE,
    TIME_INTO_DAY,
    LOCALTIME_INTO_DAY,
    STROKE_TYPE,
    BODY_LOCATION,
    SEGMENT_LAP_STATUS,
    SEGMENT_LEADERBOARD_TYPE,
    SEGMENT_DELETE_STATUS,
    SEGMENT_SELECTION_TYPE,
    SOURCE_TYPE,
    LOCAL_DEVICE_TYPE,
    BLE_DEVICE_TYPE,
    ANT_CHANNEL_ID,
    DISPLAY_ORIENTATION,
    WORKOUT_EQUIPMENT,
    WATCHFACE_MODE,
    DIGITAL_WATCHFACE_LAYOUT,
    ANALOG_WATCHFACE_LAYOUT,
    RIDER_POSITION_TYPE,
    POWER_PHASE_TYPE,
    CAMERA_EVENT_TYPE,
    SENSOR_TYPE,
    BIKE_LIGHT_NETWORK_CONFIG_TYPE,
    COMM_TIMEOUT_TYPE,
    CAMERA_ORIENTATION_TYPE,
    ATTITUDE_STAGE,
    ATTITUDE_VALIDITY,
    AUTO_SYNC_FREQUENCY,
    EXD_LAYOUT,
    EXD_DISPLAY_TYPE,
    EXD_DATA_UNITS,
    EXD_QUALIFIERS,
    EXD_DESCRIPTORS,
    AUTO_ACTIVITY_DETECT,
    SUPPORTED_EXD_SCREEN_LAYOUTS,
    FIT_BASE_TYPE,
    TURN_TYPE,
    BIKE_LIGHT_BEAM_ANGLE_MODE,
    FIT_BASE_UNIT,
    SET_TYPE,
    MAX_MET_CATEGORY,
    EXERCISE_CATEGORY,
    BENCH_PRESS_EXERCISE_NAME,
    CALF_RAISE_EXERCISE_NAME,
    CARDIO_EXERCISE_NAME,
    CARRY_EXERCISE_NAME,
    CHOP_EXERCISE_NAME,
    CORE_EXERCISE_NAME,
    CRUNCH_EXERCISE_NAME,
    CURL_EXERCISE_NAME,
    DEADLIFT_EXERCISE_NAME,
    FLYE_EXERCISE_NAME,
    HIP_RAISE_EXERCISE_NAME,
    HIP_STABILITY_EXERCISE_NAME,
    HIP_SWING_EXERCISE_NAME,
    HYPEREXTENSION_EXERCISE_NAME,
    LATERAL_RAISE_EXERCISE_NAME,
    LEG_CURL_EXERCISE_NAME,
    LEG_RAISE_EXERCISE_NAME,
    LUNGE_EXERCISE_NAME,
    OLYMPIC_LIFT_EXERCISE_NAME,
    PLANK_EXERCISE_NAME,
    PLYO_EXERCISE_NAME,
    PULL_UP_EXERCISE_NAME,
    PUSH_UP_EXERCISE_NAME,
    ROW_EXERCISE_NAME,
    SHOULDER_PRESS_EXERCISE_NAME,
    SHOULDER_STABILITY_EXERCISE_NAME,
    SHRUG_EXERCISE_NAME,
    SIT_UP_EXERCISE_NAME,
    SQUAT_EXERCISE_NAME,
    TOTAL_BODY_EXERCISE_NAME,
    TRICEPS_EXTENSION_EXERCISE_NAME,
    WARM_UP_EXERCISE_NAME,
    RUN_EXERCISE_NAME,
    WATER_TYPE,
    TISSUE_MODEL_TYPE,
    DIVE_GAS_STATUS,
    DIVE_ALERT,
    DIVE_ALARM_TYPE,
    DIVE_BACKLIGHT_MODE,
    SLEEP_LEVEL,
    SPO2_MEASUREMENT_TYPE,
    CCR_SETPOINT_SWITCH_MODE,
    DIVE_GAS_MODE,
    FAVERO_PRODUCT,
    SPLIT_TYPE,
    CLIMB_PRO_EVENT,
    GAS_CONSUMPTION_RATE_TYPE,
    TAP_SENSITIVITY,
    RADAR_THREAT_LEVEL_TYPE,
    MAX_MET_SPEED_SOURCE,
    MAX_MET_HEART_RATE_SOURCE,
    HRV_STATUS,
    NO_FLY_TIME_MODE

JsHRCurve

A heart rate duration curve.

  • secs int[] ~ Time points. Note that not all seconds are included. The curve gets sparse as time goes out.
  • bpm int[] ~ HR for corresponding entry in secs.
  • start_index int[] ~ Where corresponding point starts in the activity
  • end_index int[] ~ Where corresponding point ends in the activity (exclusive)
  • indexOf(int seconds) int ~ What is the index of the point on the curve that has a duration of at least seconds? Returns -1 if the curve
    is not that long.
  • getBpm(int seconds) Integer

JsPaceCurve

A pace duration curve.

  • isGap boolean ~ Is this gradient adjusted pace?
  • distance float[] ~ Distance points. Note that not all distances are included. The curve gets sparse as time goes out.
  • secs int[] ~ Time to cover the matching distance.
  • start_index int[] ~ Where corresponding point starts in the activity
  • end_index int[] ~ Where corresponding point ends in the activity (exclusive)
  • indexOf(float distance) int ~ What is the index of the point on the curve that has a distance of at least distance? Returns -1 if the curve
    is not that long.
  • getSpeed(float distance) Float ~ Returns speed in meters/second or null if curve not that long. Note that the distance might be more than the
    distance parameter.

JsPowerCurve

A power duration curve.

  • secs int[] ~ Time points. Note that not all seconds are included. The curve gets sparse as time goes out.
  • watts int[] ~ Power for corresponding entry in secs.
  • watts_per_kg float[] ~ Power/weight for corresponding entry in secs.
  • start_index int[] ~ Where corresponding point starts in the activity
  • end_index int[] ~ Where corresponding point ends in the activity (exclusive)
  • after_kj int ~ If the curve is fatigued then this is the amount of work done before the curve.
  • vo2max_5m Float ~ VO2max calculated from 5m watts/kg
  • compound_score_5m Float ~ Compound score calculated from 5m watts/kg
  • indexOf(int seconds) int ~ What is the index of the point on the curve that has a duration of at least seconds? Returns -1 if the curve
    is not that long.
  • getWatts(int seconds) Integer
  • getWattsPerKg(int seconds) Float

JsStreamData

Data for a custom activity stream. There is one entry for each record message used from the fit file. The time
of each entry is the timestamp of the corresponding record less the startTimestamp of first record used i.e.
seconds since the start of the activity. Acts as an array but setAt(timestamp, value) is likely the easiest
way to fill it with data.

  • startTimestamp int ~ Start of the activity stream in seconds since UTC 00:00 Dec 31 1989
  • duration int ~ Duration of the activity in seconds
  • time List<Integer> ~ The seconds trace (first entry is 0) since the start of the activity
  • setAt(int timestamp, Number value) void ~ Set the value at the closest position on or after timestamp. If timestamp is before the start of the stream or
    after the end then nothing is done. The timestamp parameter is seconds since UTC 00:00 Dec 31 1989 which is
    the standard way timestamps are stored in fit files.

SportSettings

FTP, training zones etc. for some sports.

  • id int
  • athlete_id String
  • types ActivityType[]
  • warmup_time Integer
  • cooldown_time Integer
  • ftp Integer
  • indoor_ftp Integer
  • w_prime Integer
  • power_zones int[]
  • sweet_spot_min Integer
  • sweet_spot_max Integer
  • power_spike_threshold Integer
  • power_zone_names String[]
  • ftp_est_min_secs Integer
  • use_laps_for_power_intervals Boolean
  • keep_all_laps_for_power_intervals Boolean
  • after_kj0 Integer
  • after_kj1 Integer
  • power_field String
  • lthr Integer
  • max_hr Integer
  • hr_zones int[]
  • hr_zone_names String[]
  • hr_load_type HRLoadModel.Type
  • hrrc_min_percent Float
  • threshold_pace Float
  • pace_units PaceUnits
  • pace_zones float[]
  • pace_zone_names String[]
  • pace_load_type PaceTssCalc.Type
  • gap_model GapModel
  • elevation_correction SportSettings.ElevationCorrection
  • use_gap_zone_times Boolean
  • best_effort_distances float[]
  • pace_curve_start Float
  • load_order ZoneOrder ~ Priority for calculating training load
  • tiz_order ZoneOrder ~ Priority for calculating time in zones
  • workout_order ZoneOrder ~ Priority for executing workouts
  • interval_display ZoneOrder ~ Priority for displaying intervals
  • default_gear_id String
  • default_indoor_gear_id String
  • extract_workouts Boolean ~ Extract workouts from activity files if possible
  • show_pauses Integer
  • ignore_velocity Boolean

PaceUnits

Units for threshold pace.

  • SECS_100M, SECS_100Y, MINS_KM, MINS_MILE, SECS_500M

SportSettings.ElevationCorrection

  • NO, AUTO, YES

Wellness

Daily values for an athlete. Read and write custom fields from JavaScript using wellness.[field code].

  • id String
  • ctl Float
  • atl Float
  • rampRate Float
  • ctlLoad Float
  • atlLoad Float
  • sportInfo List<WellnessFitness.SportInfo>
  • weight Float
  • restingHR Integer
  • hrv Float ~ rMSSD
  • hrvSDNN Float
  • menstrualPhase MenstrualPhase
  • menstrualPhasePredicted MenstrualPhase
  • kcalConsumed Integer
  • sleepSecs Integer
  • sleepScore Float
  • sleepQuality Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • avgSleepingHR Float
  • soreness Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • fatigue Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • stress Integer ~ None(0), Low(1), Avg(2), High(3), Extreme(4)
  • mood Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • motivation Integer ~ Poor(4), Avg(3), Good(2), Excellent(1)
  • injury Integer ~ Injured(4), Poor(3), Niggle(2), Excellent(1)
  • spO2 Float ~ 0-100%
  • systolic Integer ~ blood pressure mmHg
  • diastolic Integer
  • hydration Integer ~ Well Hydrated (1), Hydrated(2), Dehydrated(3), Very Dehydrated(4)
  • hydrationVolume Float ~ litres consumed
  • readiness Float
  • baevskySI Float
  • bloodGlucose Float ~ mmol/L
  • lactate Float ~ mmol/L
  • bodyFat Float ~ %
  • abdomen Float ~ cm
  • vo2max Float ~ ml/kg/min
  • comments String
  • customFields Map<String, Object>
  • tempWeight boolean ~ Indicates value was updated from athlete settings and is not authoritative
  • tempRestingHR boolean

WellnessFitness.SportInfo

MenstrualPhase

  • PERIOD, FOLLICULAR, OVULATING, LUTEAL, NONE
4 Likes

I just added some more objects for working with fit files to the ActivityJsData ‘icu’ object

is it possible to calculate for a specific day total activity calories burned. I basically want to stamp on the athlete record the calories burned for all activities for that day. I was looking to see if I could write a script to come up with that data and thought I would reach out first to see if it is possible. Love this ability by the way.

NVM. I see that calculated fields aren’t allowed on wellness data

Not yet but I am planning on adding that. First for simple cases like this one.