API access to Intervals.icu

I can’t say I noticed any difference; perhaps the timing was such that I was busy at the time.

Thanks for the update, at my end all is back to mode business as usual.

Was a strange week, at the beginning Google AppScript served many 500, and afterwards they kicked ICU.

1 Like

@david could you take a look at this? Understand the recent outage took a big bite out of you.

gonna delete the duplicate activity soon before I forget. :pray:

Tx

I’m trying to create a workout via API and I got an error

[{"status":422,"error":"Name is too long"}]

Workout name is Outdoor: Endurance with Tempo, Threshold Criss-Cross, Threshold efforts and sprints
Although on UI I can create a workout with that name without an error.

Is that by design?

Which endpoint are you calling? Creating a workout in a library folder or on a calendar?

In library plan
https://intervals.icu/api/v1/athlete/i55661/workouts
Request:

{"folder_id":"272551","day":12,"type":"Ride","name":"Outdoor: Endurance with Tempo, Threshold Criss-Cross, Threshold efforts and sprints","moving_time":14400,"description":"..."}

The workout name is limited to 80 chars mostly because the UI won’t handle very long names well. I have improved the error message.

Just wondering if there’s an approved method for adding/modifying a stream within an activity.

I have streams from another source that I’d like to add (fan power, temperature, humidity, pm2.5 air quality) to indoor activities that I can’t collect using device the original FIT originates from.

A idea for a workaround would involve a request to my endpoint from the custom stream generator within Intervals. A few reasons not to explore that though.

There isn’t any way to do that at the moment. Allowing calls out from custom scripts would be very powerful but has all kinds of risks particularly since streams can be shared with others and so on. If anyone has ideas on how to implement that safely please ping me.

I could add an API endpoint to add/edit custom streams for an activity, accepting CSV or JSON data. I have that feature on the todo list for the UI.

1 Like

Indeed, it would create hazards on a number of fronts.

In the meantime, I can pull the fit file and delete the activity via API, add the stream to the file, upload the file again. Is there anything to watch out fo with this approach?

That should work out fine. You can pull the file, add the stream, upload, and then delete the original activity. Intervals uses a hash of the file to detect dups so they will be seen as different.

Today I did another workout, recording on 2 Garmin devices again and this time, there was no error or rather, when I use the API to rename the activity. Only 1 activity got renamed instead of both.

But for the one last week, Just tried renaming 1 activity again thru the API and again both activities got renamed.

When you rename the activity Intervals.icu will push the new name to Strava because you have that box ticked in settings. Next time Strava activities are fetched, Intervals.icu will update one of the Garmin ones (random, could be the one with the name already or the other one) to match the Strava name.

Wow… I’m confused. Although it makes sense since Strava doesn’t have the Garmin Activity ID. But it will have the Strava Activity ID.

Doesn’t whatever that comes back from Strava (next time Strava activities are fetched) also comes with a Strava ID alongside the name?

But now I understand why today’s activities didn’t have issues (cos I deleted the one of the Strava activity before I did the renaming via API).

Okay, then. This is expected and not a bug.

Yes it does but Intervals.icu does a little search to see what other “higher priority activity” (Garmin, Suunto etc.) matches the Strava one and updates that including setting its strava_id. If there is more than one the earliest start date is picked. If there are two with the same start date then it’s random.

My assumption was that there wouldn’t be more than 1.

2 Likes

Has anyone gotten ChatGPT Actions to work?

I have tried to configure the Basic Auth with my API key as in the pic
Screenshot 2024-03-05 at 15.59.36

And tested the API endpoint /api/v1/athlete/<athlete_id>/activities but the only thing I am getting back is:

[debug] Calling HTTP endpoint
{
  "domain": "intervals.icu",
  "method": "get",
  "path": "/api/v1/athlete/i196956/activities",
  "operation": "getAthleteActivities",
  "operation_hash": "3361b50afa229b55fcd2d9bd8df5e0429377eb02",
  "is_consequential": false,
  "params": {
    "oldest": "2024-01-01",
    "newest": "2024-03-05"
  }
}
[debug] Response received
{
  "response_data": {
    "status": 500,
    "error": "java.lang.IllegalArgumentException: Last unit does not have enough valid bits"
  },
  "status_code": 500,
  "action_id": "g-f2908fa4451b7483bf04f0d0be5c91e967ca21d5"

This means that the authentication is successful (otherwise it would tell me Access Denied I guess) but then I get that.

The OpenAPI spec I am passing is taken from the docs and is like this:

openapi: 3.0.1
info:
  title: Intervals.icu API
  version: v1.0.0
servers:
  - url: https://intervals.icu
    description: Generated server url
paths:
  /api/v1/athlete/i196956/activities:
    get:
      tags:
        - Activities
      summary: List activities for a date range
      operationId: getAthleteActivities
      parameters:
        - name: oldest
          in: query
          description: Local ISO-8601 date or date and time e.g. 2019-07-22T16:18:49 or 2019-07-22
          required: true
          schema:
            type: string
        - name: newest
          in: query
          description: Local ISO-8601 date or date and time
          required: true
          schema:
            type: string
      responses:
        "200":
          description: OK
          content:
            "*/*":
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Activity"

Any help would be appreciated, thanks! :pray:

Ps. I tried with curl and it all works fine

curl -X GET "https://intervals.icu/api/v1/athlete/i196956/activities?oldest=2024-01-01&newest=2024-03-01" \
 -H "authorization: Basic ***" \

So it must be something that ChatGPT does that intervals.icu doesn’t like, but it’s hard to know what, as I only get the debug information above, which seem it’s calling it right.

Hi all,

I’m looking to download the ‘feel’ metric for the past year with an API call. Each of my activities has a value assigned, but it’s not included with the wellness data download.

I have a custom item (chart) that plots the data, and I see there is a way to download the csv data manually on the website. Is there a way to download the same data over a given date range through the api?

Thanks in advance.

Yes but you need to download the activities and not the wellness data. Feel is per-activity. The fitness plots aggregate per activity things like feel into a single value for the day but that is all done client side.

Use this endpoint: GET /api/v1/athlete/{id}/activities

Excellent, thank you!

Hi all,

may I ask if it would be possible to include athletes reference values settings in the event response. So to make my question clear, for example when bike workout is prescribed with Power in W and I would like to get that raw power numbers from W to % of FTP I have to call GET api/v1/athlete/{athlete_id} and then extract FTP from there and only then I can calculate %FTP for the workout. The same goes when workout is prescribed as zones where I have to extract power settings and then zones to calculate average of the zone to have it as % of FTP.

Would it be possible to include those reference settings in the event response object. So for example in Gravel Ride workout only reference settings that are valid for thta type would be included(Power, Heart Rate), for run workouts only run reference settings would be included(Pace, Heart Rate, Power).

Would that be possible? I am sorry if this has already been questioned and answered but I could not find it.

Best regards