# API access to Intervals.icu

**URL:** <https://forum.intervals.icu/t/api-access-to-intervals-icu/609>\
**Category:** Guide\
**Created:** [1 April 2020 16:18 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609 "2020-04-01T16:18:59Z")\
**Posts on this page:** 20\
**Page:** 7

<div class="post-metadata">

**Author:** ![Rohan\_EnduroCo](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@Rohan\_EnduroCo](https://forum.intervals.icu/u/Rohan_EnduroCo)\
**Post date:** [15 March 2022 10:59 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/121 "2022-03-15T10:59:56Z")

</div>

Thanks David. Issue was with the permission.

Yes I was trying to post planned workouts. Its working now.

---

<div class="post-metadata">

**Author:** ![Someone\_Else](https://forum.intervals.icu/user_avatar/forum.intervals.icu/someone_else/32/33978_2.png) [@Someone\_Else](https://forum.intervals.icu/u/Someone_Else)\
**Post date:** [17 March 2022 12:59 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/122 "2022-03-17T12:59:36Z")

</div>

Hi,

Is there some kind full documentation of all available REST API endpoints?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [17 March 2022 15:54 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/123 "2022-03-17T15:54:34Z")

</div>

Unfortunately not yet. However many mirror the private API endpoints used by the Intervals.icu web app. So you can use the inspector to see what to send and what comes back. Replace /api/ with /api/v1/ in the path.

I need to get API docs done. Keen to have lots of stuff integrating with Intervals.icu.

---

<div class="post-metadata">

**Author:** ![Holly\_Woodford](https://forum.intervals.icu/user_avatar/forum.intervals.icu/holly_woodford/32/8421_2.png) [@Holly\_Woodford](https://forum.intervals.icu/u/Holly_Woodford)\
**Post date:** [21 March 2022 17:29 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/124 "2022-03-21T17:29:49Z")

</div>

Hi David, loving using Intervals.icu. I am co-founder of Her Spirit which is a running, swimming, cycling and triathlon community for women. We are encouraging some of our members to sign up and use it. They are really loving the experience. Is it possible with the api to create an authenticated link between our app and Intervals to automatically log members in or create a new account for a new sign up? Many thanks Holly

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [21 March 2022 17:38 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/125 "2022-03-21T17:38:46Z")

</div>

Thanks! Yes what you are asking for exists. I will be in touch shortly.

---

<div class="post-metadata">

**Author:** ![Rohan\_EnduroCo](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@Rohan\_EnduroCo](https://forum.intervals.icu/u/Rohan_EnduroCo)\
**Post date:** [23 March 2022 06:05 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/126 "2022-03-23T06:05:08Z")

</div>

Hi @david  
As per the post it supports these 3.

> [@david](#):
>
> zwo, mrc and erg files.

Issue is that they don’t support HR and Pace based workouts.

Can we also use the ICU JSON Workout format to post workouts?

Edit  
Tried myself and got the answer. Even though its not documented posting with JSON works. My guess is thats the best way to post HR and Pace based workouts

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [24 March 2022 14:57 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/127 "2022-03-24T14:57:32Z")

</div>

Cool. Posting Intervals.icu text is the best way if you can because all features are supported.

---

<div class="post-metadata">

**Author:** ![snoopy](https://forum.intervals.icu/user_avatar/forum.intervals.icu/snoopy/32/27139_2.png) [@snoopy](https://forum.intervals.icu/u/snoopy)\
**Post date:** [24 March 2022 15:10 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/128 "2022-03-24T15:10:28Z")

</div>

@Rohan_EnduroCo can you share a sample of JSON wor HR and Pace workouts?

---

<div class="post-metadata">

**Author:** ![Rohan\_EnduroCo](https://forum.intervals.icu/letter_avatar_proxy/v4/letter/r/5f9b8f/32.png) [@Rohan\_EnduroCo](https://forum.intervals.icu/u/Rohan_EnduroCo)\
**Post date:** [25 March 2022 06:24 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/129 "2022-03-25T06:24:09Z")

</div>

@snoopy easiest way is go to intervals and download any workout. One example below is for power. But you can easily change that.

```auto
{
  "athlete_id": null,
  "id": null,
  "icu_training_load": null,
  "name": "CSP15 Cycling Speed Play 79m [Cap] #enduroco.in",
  "description": null,
  "type": "Ride",
  "indoor": null,
  "color": null,
  "moving_time": null,
  "updated": null,
  "joules": null,
  "joules_above_ftp": null,
  "workout_doc": {
    "duration": 4740,
    "steps": [
      { "duration": 600, "power": { "value": 43, "units": "%ftp" } },
      { "duration": 900, "power": { "value": 65, "units": "%ftp" } },
      {
        "reps": 6,
        "text": "6x",
        "steps": [
          { "duration": 120, "power": { "value": 98, "units": "%ftp" } },
          { "duration": 120, "power": { "value": 43, "units": "%ftp" } }
        ],
        "duration": 1440
      },
      { "duration": 900, "power": { "value": 65, "units": "%ftp" } },
      { "duration": 900, "power": { "value": 43, "units": "%ftp" } }
    ],
    "zoneTimes": [
      {
        "id": "Z1",
        "zone": 1,
        "name": "Z1",
        "color": "#009e80",
        "max": 55,
        "minWatts": 1,
        "maxWatts": 129,
        "percentRange": "0% - 55%",
        "secs": 2220
      },
      {
        "id": "Z2",
        "zone": 2,
        "name": "Z2",
        "color": "#009e00",
        "max": 75,
        "minWatts": 130,
        "maxWatts": 176,
        "percentRange": "56% - 75%",
        "secs": 1800
      },
      {
        "id": "Z3",
        "zone": 3,
        "name": "Z3",
        "color": "#ffcb0e",
        "max": 90,
        "minWatts": 177,
        "maxWatts": 211,
        "percentRange": "76% - 90%",
        "secs": 0
      },
      {
        "id": "Z4",
        "zone": 4,
        "name": "Z4",
        "color": "#ff7f0e",
        "max": 105,
        "minWatts": 212,
        "maxWatts": 246,
        "percentRange": "91% - 105%",
        "secs": 720
      },
      {
        "id": "Z5",
        "zone": 5,
        "name": "Z5",
        "color": "#dd0447",
        "max": 120,
        "minWatts": 247,
        "maxWatts": 282,
        "percentRange": "106% - 120%",
        "secs": 0
      },
      {
        "id": "Z6",
        "zone": 6,
        "name": "Z6",
        "color": "#6633cc",
        "max": 150,
        "minWatts": 283,
        "maxWatts": 352,
        "percentRange": "121% - 150%",
        "secs": 0
      },
      {
        "id": "Z7",
        "zone": 7,
        "name": "Z7",
        "color": "#504861",
        "max": 999,
        "minWatts": 353,
        "maxWatts": 9999,
        "percentRange": "151% +",
        "secs": 0
      },
      {
        "id": "SS",
        "zone": 8,
        "name": "Sweet Spot",
        "color": "#ffa00e",
        "gap": true,
        "min": 84,
        "minWatts": 197,
        "max": 97,
        "maxWatts": 227,
        "percentRange": "84% - 97%",
        "secs": 0
      }
    ],
    "ftp": 235
  },
  "folder_id": null,
  "day": null,
  "days": null,
  "plan_applied": null,
  "hide_from_athlete": null,
  "target": null,
  "icu_intensity": null
}

```

 ![workout 1](https://forum.intervals.icu/uploads/default/original/2X/8/861321ada69ea748f8f8c27f8df177a29741c67e.png)

---

<div class="post-metadata">

**Author:** ![Markus\_Unterweger](https://forum.intervals.icu/user_avatar/forum.intervals.icu/markus_unterweger/32/8985_2.png) [@Markus\_Unterweger](https://forum.intervals.icu/u/Markus_Unterweger)\
**Post date:** [29 March 2022 17:06 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/130 "2022-03-29T17:06:27Z")

</div>

HI There, is it possible to get the detailed metrics of an activitie trough the api? i think of detecting anomalies in the power or heart rate data… thanks

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [29 March 2022 18:36 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/131 "2022-03-29T18:36:06Z")

</div>

Yes you can:

```
GET /api/v1/activity/{id}/streams?types=raw_watts,watts

```

You can find out the types by looking at the calls made by the web app in the inspector. The watts and heartrate streams include info on anomalies detected and fixed by Intervals.icu.

You can also tack on .csv to get CSV data instead of JSON.

---

<div class="post-metadata">

**Author:** ![Joen\_Tolgraven](https://forum.intervals.icu/user_avatar/forum.intervals.icu/joen_tolgraven/32/9029_2.png) [@Joen\_Tolgraven](https://forum.intervals.icu/u/Joen_Tolgraven)\
**Post date:** [30 March 2022 23:41 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/132 "2022-03-30T23:41:57Z")

</div>

Trying to use the endpoints from an SPA (which does have a back-end I could use, but prefer not to since using Firebase heavily, including caching stuff like this) and running into CORS issues. Is there any specific reason for this restriction?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [31 March 2022 04:56 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/133 "2022-03-31T04:56:28Z")

</div>

CORS isn’t supported because I didn’t need it for the Intervals.icu front-end and it is safer to keep things turned off. I could turn it on but need to be careful about security. Maybe only for /api/v1/ endpoints with `Access-Control-Allow-Headers: Authorization`? Would that work for your SPA?

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [1 April 2022 05:27 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/134 "2022-04-01T05:27:43Z")

</div>

@david This post will consist of 2 items:

1. Possible Bug  
Within Intervals.icu, one can have 2 different FTP settings (outdoor and indoors).  
Hence for workout creation there is an option to mark it as “indoors”. What I found out was that this setting does not trigger the FTP to be updated in the ERG and JSON file downloads. (ERG & JSON file download will still be using Outdoors FTP with FTP = 200 on the ERG download)  

2. Additional Data Request for API  
Recently saw that you enabled JSON based workout export/downloads (download.json) and I’m playing around with this as it may afford some better flexibility vs MRC/ERG files. For Power Based structured workouts downloaded as JSON, there is the inclusion of the user’s FTP to be able to change the workout structure from %FTP and Absolute Watt if necessary.

For HR Based workouts (I didn’t test pace), the user’s MaxHR or LTHR is not included into the workout JSON. Would it be possible to also include either of these depending on the user’s pref into the JSON same as FTP pref? (indoor/outdoor - but just named as FTP)? Right now, HR based workouts editing can only support %HR (and not absolute HR) so Its gonna take another API call to get the MaxHR/LTHR data and even then I do not know if there’s a flag to indicate the user is creating the workout using MaxHR or LTHR.

TQ for your consideration.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [1 April 2022 07:39 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/135 "2022-04-01T07:39:50Z")

</div>

> [@app4g](#):
>
> What I found out was that this setting does not trigger the FTP to be updated in the ERG and JSON file downloads

I did some testing and this was broken from the Intervals.icu web app (the indoor flag not passed through). I have fixed that. So if you call `/api/v1/athlete/{id}/download-workout{ext}` you need to include `"indoor" true` in the payload.

This endpoint works: `/api/v1/athlete/{id}/events/{eventId}/download{ext}`.

> [@app4g](#):
>
> For HR Based workouts (I didn’t test pace), the user’s MaxHR or LTHR is not included into the workout JSON.

I have added lthr, max\_hr, threshold\_pace and pace\_units. Note that threshold\_pace is always in mps and the pace\_units field is just so it can be correctly displayed to the user:

```
SECS_100M(false),
SECS_100Y( true),
MINS_KM(false),
MINS_MILE(true),
SECS_500M(false);

```

---

<div class="post-metadata">

**Author:** ![app4g](https://forum.intervals.icu/user_avatar/forum.intervals.icu/app4g/32/41800_2.png) [@app4g](https://forum.intervals.icu/u/app4g)\
**Post date:** [1 April 2022 10:56 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/136 "2022-04-01T10:56:08Z")

</div>

TQ So Much…

intervals.icu web-app front end downloads the ERG w/ the correct FTP (based on the flag)

I’m using this end point “[https://intervals.icu/api/v1/athlete/(athleteId)/events/(workoutId)/download.json](https://intervals.icu/api/v1/athlete/(athleteId)/events/(workoutId)/download.json)” and I can also see the maxHR / LTHR and all the ones you added (for pace - i think this would come in handy later)

TQ So much for this…

---

<div class="post-metadata">

**Author:** ![Joen\_Tolgraven](https://forum.intervals.icu/user_avatar/forum.intervals.icu/joen_tolgraven/32/9029_2.png) [@Joen\_Tolgraven](https://forum.intervals.icu/u/Joen_Tolgraven)\
**Post date:** [2 April 2022 13:51 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/137 "2022-04-02T13:51:19Z")

</div>

@david yes please!

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [3 April 2022 09:48 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/138 "2022-04-03T09:48:41Z")

</div>

I just deployed CORS support for /api/v1/ endpoints. Supposedly you should be able to supply an Authorization header. I was a bit lazy and haven’t actually tested it but was simple cut and paste from another project so it should work.

---

<div class="post-metadata">

**Author:** ![Joen\_Tolgraven](https://forum.intervals.icu/user_avatar/forum.intervals.icu/joen_tolgraven/32/9029_2.png) [@Joen\_Tolgraven](https://forum.intervals.icu/u/Joen_Tolgraven)\
**Post date:** [3 April 2022 17:49 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/139 "2022-04-03T17:49:52Z")

</div>

Thanks a lot! All smooth now.  
Tho I was banging my head not getting it working, because I was going off info at top of thread to use my strava athlete ID. Might want to put a note about the change in early posts/examples?

Edit: aaaand this is where I realize with no access control to enforce read-only I guess this will leave me open to having everything nuked by anyone haha. Guess I’ll move it to back-end after all… well, eventually. #live4danger

---

<div class="post-metadata">

**Author:** ![DAVIDE\_L](https://forum.intervals.icu/user_avatar/forum.intervals.icu/davide_l/32/34453_2.png) [@DAVIDE\_L](https://forum.intervals.icu/u/DAVIDE_L)\
**Post date:** [5 April 2022 19:22 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/140 "2022-04-05T19:22:23Z")

</div>

would there be a possibility to have the gear data in the api results? Thanks

[Previous page](https://forum.intervals.icu/t/api-access-to-intervals-icu/609.md?page=6)

[Next page](https://forum.intervals.icu/t/api-access-to-intervals-icu/609.md?page=8)
