# 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:** 19

<div class="post-metadata">

**Author:** ![johannesh83](https://forum.intervals.icu/user_avatar/forum.intervals.icu/johannesh83/32/28688_2.png) [@johannesh83](https://forum.intervals.icu/u/johannesh83)\
**Post date:** [3 January 2024 11:50 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/365 "2024-01-03T11:50:51Z")

</div>

Thanks for this very quick reply.

I have to apologize. In so many situations, the issue was sitting in front of the screen. With too much refactoring I introduced a check too much. Could solve it in the meantime. Stuff works.

**The set of APIs exposed from ICU is pretty amazing. Really! Thanks.**

Background: I am not that happy when changing the HR-Zones, that all historical LTHR could not be simply kept. For this reason a script does the job to correct them.

 ![image](https://forum.intervals.icu/uploads/default/original/3X/7/9/791c9ab6fe2eb3d3fd28f9996600a001b803ce2f.png)

---

<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:** [4 January 2024 11:45 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/366 "2024-01-04T11:45:00Z")

</div>

> [@david](#):
>
> If you got a 429 then you did hit a rate limit. Just slow down the calls a bit. But I am not seeing any 429s in the logs? Validation errors will return a 422. What error did you get?

Limited I mean, ZWO doesn’t support target range, which I like to see in my workouts.

> [@david](#):
>
> ```auto
> "file_contents_base64": "string", // fit file contents
> "filename": "string", // workout.fit or whatever
> 
> ```

Beautiful, thank you

---

<div class="post-metadata">

**Author:** ![tlgs](https://forum.intervals.icu/user_avatar/forum.intervals.icu/tlgs/32/61071_2.png) [@tlgs](https://forum.intervals.icu/u/tlgs)\
**Post date:** [4 January 2024 15:40 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/367 "2024-01-04T15:40:21Z")

</div>

> [@johannesh83](#):
>
> Background: I am not that happy when changing the HR-Zones, that all historical LTHR could not be simply kept.

I agree with this – @david, could you chime in?

I assume that it’s like this because FTP and Threshold Pace should change much more often than LTHR, but I think that it should be kept for previous activities if there’s a need to Re-analyze (e.g. to compute a new field).

---

<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:** [4 January 2024 20:01 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/368 "2024-01-04T20:01:20Z")

</div>

I did some tests and LTHR **is changed** when you do Actions → Update zones under the ride timeline chart or use the activity list view to do the same.

 ![Screenshot 2024-01-04 at 22.00.09](https://forum.intervals.icu/uploads/default/original/3X/3/4/343b6549c97fe455bf4a7cb241069b40c20a9db1.png)

(edit 2023-01-06: I must have been half asleep when I tested this before and said it didn’t change LTHR)

---

<div class="post-metadata">

**Author:** ![tlgs](https://forum.intervals.icu/user_avatar/forum.intervals.icu/tlgs/32/61071_2.png) [@tlgs](https://forum.intervals.icu/u/tlgs)\
**Post date:** [5 January 2024 17:38 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/369 "2024-01-05T17:38:51Z")

</div>

Is that the same behavior for Re-analyze?

Also, does that mean that you’re not able to change the LTHR for an activity like you can with FTP/Threshold Pace?

---

<div class="post-metadata">

**Author:** ![johannesh83](https://forum.intervals.icu/user_avatar/forum.intervals.icu/johannesh83/32/28688_2.png) [@johannesh83](https://forum.intervals.icu/u/johannesh83)\
**Post date:** [5 January 2024 20:42 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/370 "2024-01-05T20:42:37Z")

</div>

Hello @William_Barnes ,

stumpled across this section in your gscripts. Looks like it didn´t really work for you:

```auto
function populateSheetWithJSON(sheet, csvUrl) {
   var resp = ImportJSON(csvUrl);
      sheet.getRange(
         1, 1,
         resp.length /* rows */,
         resp[0].length /* columns */).clearContent().setValues(resp);
   }

```

This one shall do the job, at least I could download for example all events via API and parse it from JSON to a table in sheets

```auto
function populateSheetWithJSON(sheet, csvUrl) {
   var resp = ImportJSON(csvUrl);
   const max = Math.max(...resp.map(r => r.length));
   resp = resp.map(r => r.length < max ? [...r, ...Array(max - r.length)] : r);
   sheet.getRange(1, 1)
       .offset(0, 0, resp.length, resp[0].length)
       .setValues(resp);
   }

```

```auto
 var sheet_json = SpreadsheetApp.getActive().getSheetByName('intervals.icu_events-export');
 populateSheetWithJSON(sheet_json,"https://API_KEY:" + API_KEY + "@intervals.icu/api/v1/athlete/" + athleteID + "/events?oldest=YYYY-MM-DD&newest=YYYY-MM-DD");

```

@david any plans for exposing all events from ICU also as CSV via API? (like we have with wellness or the activities) That would be nice and very helpful in many situations for others as well to either use it for programmatically further usage or to simply get an overview of all events in a list. Many thanks.

I thought you might be interested in as I made some step to fix it, but there is still sth weird and buggy. Handling NULL values seems to be issue when I look to my results in the table. It does not skip them and just copy from the one before. I assume the issue is being caused at `function parseJSONObject_`, during `transformData_` the NULL values are not considered, but I stuck from there solving it.

 ![Bildschirmfoto 2024-01-05 um 22.15.20](https://forum.intervals.icu/uploads/default/original/3X/a/6/a666aea803baaddb6a99ed669fdb7d0b30cad600.png)

Best,  
Johannes

---

<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:** [6 January 2024 11:50 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/371 "2024-01-06T11:50:56Z")

</div>

I have just updated my post. Must have been half asleep before. Doing “Update Zones” does change LTHR. Probably not the best decision but on the other hand it isn’t something that changes much.

Re-analyze does not change zones, LTHR, FTP or threshold pace. All history is kept.

---

<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:** [7 January 2024 05:47 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/372 "2024-01-07T05:47:17Z")

</div>

> [@johannesh83](#):
>
> any plans for exposing all events from ICU also as CSV via API?

You can now download the events in CSV format. Just add .csv to the path.

---

<div class="post-metadata">

**Author:** ![johannesh83](https://forum.intervals.icu/user_avatar/forum.intervals.icu/johannesh83/32/28688_2.png) [@johannesh83](https://forum.intervals.icu/u/johannesh83)\
**Post date:** [7 January 2024 11:07 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/373 "2024-01-07T11:07:40Z")

</div>

**Bähm** 🎉… easy catch! Appreciated. Thx.

Leave from outside a huge impression of a proper designed code base and well-done contracts.

---

<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:** [16 January 2024 20:05 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/374 "2024-01-16T20:05:30Z")

</div>

> [@david](#):
>
> ```auto
> "file_contents_base64": "string", // fit file contents
> 
> ```

Is it possible to upload activities the same way, by providing base64 string?

---

<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 January 2024 04:10 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/375 "2024-01-17T04:10:00Z")

</div>

No you need to use this endpoint for activities: [POST /api/v1/athlete/{id}/activities](https://intervals.icu/api-docs.html#post-/api/v1/athlete/-id-/activities)

Activity files can be very big.

---

<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:** [18 January 2024 16:44 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/376 "2024-01-18T16:44:54Z")

</div>

When endpoint `GET /api/v1/athlete/{athleteId}/activities` returns an empty array, the response doesn’t have `content-type` header. If the response returns a non-empty array, content-type is present.  
Could you fix it, and add header for all cases?

---

<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:** [18 January 2024 18:35 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/377 "2024-01-18T18:35:34Z")

</div>

Ohh I fixed that and a couple of others. Sorry about that. Will deploy Friday AM (GMT+2).

---

<div class="post-metadata">

**Author:** ![Vicente\_Urruticoeche](https://forum.intervals.icu/user_avatar/forum.intervals.icu/vicente_urruticoeche/32/27010_2.png) [@Vicente\_Urruticoeche](https://forum.intervals.icu/u/Vicente_Urruticoeche)\
**Post date:** [26 January 2024 16:59 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/378 "2024-01-26T16:59:03Z")

</div>

Has anyone manadged to Authenticate with the ChatGPT custom actions interface from GPTBuilder?

 ![Screenshot 2024-01-26 at 13.58.54](https://forum.intervals.icu/uploads/default/original/3X/5/1/5137171a3a23fca74317e60ff657fed593e50a6b.png)

---

<div class="post-metadata">

**Author:** ![johannesh83](https://forum.intervals.icu/user_avatar/forum.intervals.icu/johannesh83/32/28688_2.png) [@johannesh83](https://forum.intervals.icu/u/johannesh83)\
**Post date:** [28 January 2024 17:43 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/379 "2024-01-28T17:43:47Z")

</div>

OAuth isn’t available for most common users as far as I know.

Did you try with an API Key?

Anyway, what do wanna ask Chat GPT? Would be interested in understanding your use case.

---

<div class="post-metadata">

**Author:** ![Vicente\_Urruticoeche](https://forum.intervals.icu/user_avatar/forum.intervals.icu/vicente_urruticoeche/32/27010_2.png) [@Vicente\_Urruticoeche](https://forum.intervals.icu/u/Vicente_Urruticoeche)\
**Post date:** [30 January 2024 14:06 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/380 "2024-01-30T14:06:46Z")

</div>

Hi! I actually did try with the API, but cant manage to get the call working.

I actually have cero dev experiance 😅

I would love to access my data in natural language and be able to analyse it.

---

<div class="post-metadata">

**Author:** ![MedTechCD](https://forum.intervals.icu/user_avatar/forum.intervals.icu/medtechcd/32/40383_2.png) [@MedTechCD](https://forum.intervals.icu/u/MedTechCD)\
**Post date:** [30 January 2024 14:40 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/381 "2024-01-30T14:40:02Z")

</div>

Try this:

Authentication Type: API Key  
Client ID: API\_KEY _ **This text and not your apikey!!** _  
Client Secret: Your Apikey found on the Intervals settings page  
Authorization URL: [https://intervals.icu/api/v1/athlete/AthleteID/activities.csv](https://intervals.icu/api/v1/athlete/AthleteID/activities.csv) Where AthleteID is **your ID** found on the intervals settings page

---

<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:** [4 February 2024 20:59 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/382 "2024-02-04T20:59:09Z")

</div>

Hi,

In my application i would like to convert workout step target from zone to actual ftp percentage (Z1 = 0% - 55%).  
I’m thinking to use `zoneTimes` field from endpoint `api/v1/athlete/.../events` it has perfect zone description

```auto
"zoneTimes": [
  {
    "id": "Z1",
    "max": 55,
    "name": "Z1",
    "secs": 0,
    "zone": 1,
    "color": "#009e80",
    "maxWatts": 132,
    "minWatts": 1,
    "percentRange": "0% - 55%"
  },
  ...

```

My question, is it ok to use it or there is different rest endpoint which can return zone description?  
If current one is ok, could you please add additional object to zone description, which contains percentage range not in string, but in int values. e.g.

```auto
"zoneTimes": [
  {
    ...
    "range": {
      "min": 0
      "max": 55
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![Nik\_Om\_Cinderella\_Ri](https://forum.intervals.icu/user_avatar/forum.intervals.icu/nik_om_cinderella_ri/32/36338_2.png) [@Nik\_Om\_Cinderella\_Ri](https://forum.intervals.icu/u/Nik_Om_Cinderella_Ri)\
**Post date:** [4 February 2024 22:49 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/383 "2024-02-04T22:49:19Z")

</div>

Looks like the PercentRange is exactly what you need and it’s already there. You should be able to Parse it with a delimiter.

---

<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:** [5 February 2024 05:40 UTC](https://forum.intervals.icu/t/api-access-to-intervals-icu/609/384 "2024-02-05T05:40:51Z")

</div>

You need to use this endpoint: [GET /api/v1/athlete/{id}/events{format}](https://intervals.icu/api-docs.html#get-/api/v1/athlete/-id-/events-format-)

If you add resolve=true then all the workout step targets will be expanded into actual watts/bpm/pace values using the athlete’s zones and other settings.

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

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