Partner-based API

The AI Endurance Partner API lets third party applications access data in AI Endurance. The authorization is partner-based, meaning the partner can access the data of all users associated to the partner - AI Endurance connection.

Authentication

Authentication is key based. We provide you with a partner_id and an authorization key auth_key with which you can make authorized requests via including the http header


<header> = {
  HTTP_AUTHORIZATION: Bearer <auth_key>,
  HTTP_PARTNER_ID: <partner_id>,
  Content-Type: application/json,
}
                         
in your requests.

Fit file Endpoints

api/fit_partner_ping/ POST

Send ping for a list of Fit files. The partner makes the fit files available via either of the following options:

  • The partner is making each Fit file available at the URL callback_url to be downloaded by AI Endurance.
  • The partner sends each Fit file as a base64 encoded string via json in the callback_url field.

The partner can specify different priorities depending on how fast the Fit file should be downloaded: if a user is already connected to the partner service and finishes an individual activity that should show in AI Endurance as soon as possible, use priority 1. If the user is connecting to the partner and many Fit files are being sent to AI Endurance, use priority 0. If priority 0 is used, the download is not triggered automatically. Instead, AI Endurance waits until a bulk import task is received that notifies us that the partner has now sent all Fit file pings and the bulk download/import shall begin.

Call via

curl -X POST -h '<header>' -d '<data_partner_ping>' https://aiendurance.xyz/api/fit_partner_ping/
where

<data_partner_ping> = {
  'activity_files': [
    {
      'file_type': 'FIT',
      'activity_name': 'string' (or null),
      'priority': 0, 1 (0 is lowest priority, i.e. bulk import; if not bulk import use 1),
      'user_id': 'string' (e.g. '1234'),
      'source': 'string' (e.g. 'garmin'),
      'overwrite_mode': false (true gives option to overwrite what is in db already),
      'start_time_in_seconds': 'string' (unix time stamp),
      'callback_url': 'string' (URL where Fit file can be downloaded),
      'summary_id': 'string' (file name),
    }, ...
  ]
}
            
All fields in <data_partner_ping> are required to be present.

Task Endpoints

api/task_partner/ POST

bulk_fit_transfer_complete

The following should be sent when the partner connects a user to AI Endurance and bulk sending of Fit file urls via /api/fit_partner_ping/ is complete. Only use for bulk import, for individual Fit files, use priority 1 when calling /api/fit_partner_ping/.

Call via

curl -X POST -h '<header>' -d '<data_task_bulk_fit>' https://aiendurance.xyz/api/task_partner/
where

<data_task_bulk_fit> = {
  'bulk_fit_transfer_complete': true,
  'source': 'string',
  'is_initial_import': true for user signing up for app, false for connecting later,
  'user_id': 'string',
  'event_id': 'string' (optional),
}
            

If is_initial_import = true, a new training plan is requested. If is_initial_import = false, only the Fit files are processed.

If an event_id is sent, the partner is notified at the partner specified event_url that the bulk Fit import is completed. This can take up to a few hours depending on the number of Fit files.