NAV
json

Introduction

Welcome to the Today’s Plan API.

You can use this API to upload activity files to Today’s Plan, as well as to manage your account and data.

Create your own workouts, download activity files, query for historical, summary, and aggregate data.

Through this API you can not just upload data, but you can insert, update and delete records.

The Today’s Plan API is a REST style interface which uses JSON.

All of the Today’s Plan web site and associated tools (Desktop Agent, Android app) are all built on this API.

We are slowly bringing the documentation up to speed. If you would like to perform a certain operation or data query and you can’t find it in this API doc, please don’t hesitate to contact us and we will get you the info you need.

For support, please email support@todaysplan.com.au

Servers

The main API endpoint server is located at https://whats.todaysplan.com.au

A staging/test API server server can be made available at https://staging.todaysplan.com.au - please contact us to arrange access time to this server.

Conventions

Every Object has a unique ID in the system. These are a signed 64 bit number. In the API documention these are often referenced as a Long.

All dates and times are stored in UTC as milliseconds since epoch values. These are Long numbers.

All units of measurement are presented in metric (unless otherwise stated).

Localisation

Example localisation decoration

{
  "ts": 1440669871832,
  "_ts-dst": true,
  "_ts-display": "8/27/15 8:04 PM",
  "_ts-tz": "Australia/Sydney",
  "distance": 10000,
  "_distance-display": "10.0 km",
  "duration": 14400,
  "_duration-display": "4h"
}

To assist in dealing with various timezones, locales and units of measurement preferences, all json responses are augmented with localisation data. These “decorated” values will be automatically included in each server response, and are set based on the the user’s specific timezone, locale, language etc.

The decorated fields will appear with an _ prefix and -display. eg _dueDate-display":"21/12/15".

A variety of other decorated fields exist, coverting all units of measurement, currency, date formating etc

Authentication

Introduction

The Today’s Plan API requires either the user to be in an authenticated session.

A session can be established either via a manual login, whereby a usernamd and password are presented, or it can be through the presentation of an OAuth2 token.

When a session is first established a JSESSIONID cookie is returned. This should be set in the HTTP client for all subsequent requests.

Set-Cookie = JSESSIONID=TR4t0yRVTH8esA54fX3-78yi.undefined; Path=/

When using an OAuth token, the bearer token should be placed into the header of each request. No explicit login call is needed.

Authorization: Bearer <token>

OAuth tokens

Before an access token can be requested for a user, the 3rd party developer will need to obtain a unique client_id and client secret from Today’s Plan.

Depending on the type of OAuth access request type being used, the 3rd party developer will also need to provide an authorization code URI redirect target.

ie when an authorization is requested, and the user accepts the access request, an authorization code is returned to the application via a redirect to the 3rd party website.

Once an OAuth access token has been granted for a user, this should be placed into the Authorization Bearer header for all HTTP requests.

Authorization: Bearer <token>

Two grant type (token negotiation) modes are supported;

The password grant type allows for a token to be allocated with a single command - whereby both the user’s Today’s Plan credentials and the app’s client id and client secret are presented in a single command.

The code grant type is a two phase process, and represents the more traditional OAuth token establishment, whereby the app does not ever see the user’s credentials.

Token grant by password

Response

{
  "access_token" : "2319e97c9bd9578f768b37519edc8e22"
}

POST https://whats.todaysplan.com.au/rest/oauth/access_token

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
username andrew@todaysplan.com.au The user’s Today’s Plan email
password secretstuff The user’s Today’s Plan password
client_id example The client_id assigned to the 3rd party app by Today’s Plan
client_secret abc123 The client secret assigned to the 3rd party app by Today’s Plan
grant_type password
redrect_uri https://www.example.com The app’s URL

The response to this request will be a json object with the access_token.

The expiry of the token will be determined based on the client_id / app, and if set the expiry date will be included in this response.

Token grant by authorization code

{
  "access_token" : "2319e97c9bd9578f768b37519edc8e22"
}

The code grant type is a two phase process, and represents the more traditional OAuth token establishment, whereby the app does not ever see the user’s credentials.

The first step is to redirect the user to https://whats.todaysplan.com.au/authorize/<client_id>

The user will be required to authenticate to Today’s Plan, and will then be presented with an option accept or deny the app’s access request.

A 3rd party application Example Stuff wants to access your account on your behalf - would you like to accept or deny this request.

If the user accepts the request, the user’s browser will be redirected back to the app’s URI (as registered with Today’s Plan) and an authorization code will be appended as a query parameter.

ie https://example.com/authorize?code=2319e97c9bd9578f768b37519edc8e22

The second step is for the app’s site (ie example.com) to extract the code from the query string, and issue a new multipart form POST request to Today’s Plan - presenting the code returned in the previous setp.

POST https://whats.todaysplan.com.au/rest/oauth/access_token

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
code 2319e97c9bd9578f768b37519edc8e22 The code as passed back to the application’s website
client_id example The client_id assigned to the app by Today’s Plan
client_secret abc123 The client secret assigned to the app by Today’s Plan
grant_type authorization_code
redrect_uri https://www.example.com The app’s URL

The response to this request will be a json object with an access_token.

The expiry of the token will be determined based on the client_id / app, and if set the expiry date will be included in this response.

API - Authentication

Login via username/password

Login request

{
  "username": "andrew@todaysplan.com.au",
  "password": "mypassword",
  "token": true
}

Login response

{
  "services": {
    "subscriptions": [],
    "plans": []
  },
  "canswitch": true,
  "token": "f291db13-b96b-46da-856d-ebf1f7229dc5",
  "tokenExp": 1443223617015,
  "dateformat": "d/MM/yy",
  "roles": [
    "user",
    "premium"
  ],
  "user": {
    "id": 28405,
    "email": "andrew@todaysplan.com.au",
    "firstname": "Andrew",
    "lastname": "Hall",
    "locale": "en_AU",
    "timezone": "Australia/Sydney"
  },
  "timeformat": "h:mm a"
}

POST https://whats.todaysplan.com.au/rest/auth/login

Request Parameters

Parameter Default Description
username The email address you registered to Today’s Plan with
password Your password
token false If set to true, then a bearer token will be returned in the login response. The token expiry will also be returned in the response.

Response Parameters

A variety of information relating to the user is returned. This includes the user profile, some preferences, their current services and plans. Some useful parameters are listed below;

Parameter Description
services.subscriptions Details of current analytic or coaching services
services.plans Details of current training plans
token A authorization bearer token (if requested)
tokenExp The expiry date of the issued token
roles The roles which this user is a member of. This will control what API calls are available to this user
user.* Various meta data about the user
user.locale The user’s prefered locale
user.timezone The user’s timezone

Logout

Response

true

GET https://whats.todaysplan.com.au/rest/auth/logout

API - Activity files

This service provides utilities to upload activity files, reprocess, edit and delete activity files

Add manual file

Add a manual file entry

POST https://whats.todaysplan.com.au/rest/files/manual

Input content type: application/json

Return content type: application/json

Return: VUserWorkoutFile

Inputs

Field Type Description
input UserWorkoutResult The manual values

Add manual file

Add a manual file entry against an activity

POST https://whats.todaysplan.com.au/rest/files/manual/{type:.+}/{id:.+}

Input content type: application/json

Return content type: application/json

Return: VUserWorkoutFile

Inputs

Field Type Description
type ActivityResultType The type of activity to associate with
ID Long The activity ID to associate with
input UserWorkoutResult The manual values

Bulk delete

Delete a bulk number of fileIds

POST https://whats.todaysplan.com.au/rest/files/delete

Input content type: application/json

Return content type: application/json

Return: void

Inputs

Field Type Description
collection of fileIds List

Channels

Return all the points within a file which exceed a given value

GET https://whats.todaysplan.com.au/rest/files//channel/{id:.+}/{field:.+}/{value:.+}

Return content type: application/json

Return: VFileChannel

Premium analytics

Inputs

Field Type Description
ID Long The file ID
field DataFileChannel The data channel
value Float The value to match against

Delete

Delete a user workout file

GET https://whats.todaysplan.com.au/rest/files/delete/{id:.+}

Return content type: application/json

Return: Object

Inputs

Field Type Description
id long The file ID

Download

Download the original data file

GET https://whats.todaysplan.com.au/rest/files/download/{id:.+}

Return content type: application/octet-stream

Return: Response

Premium analytics

Inputs

Field Type Description
id Long The file ID

Exists

Test if a user already has an uploaded file with the given filename

POST https://whats.todaysplan.com.au/rest/files/exists

Input content type: application/json

Return content type: application/json

Return: boolean

Inputs

Field Type Description
filename String

Manual file update

Override values in an existing file

POST https://whats.todaysplan.com.au/rest/files/update/{id:.+}

Input content type: application/json

Return content type: application/json

Return: VUserWorkoutFile

Inputs

Field Type Description
ID Long The file ID
input UserWorkoutResult The manual values

Next

Return the next set of search results for the given pagination inputs

GET https://whats.todaysplan.com.au/rest/files//page/{offset:.+}/{max:.+}

Return content type: application/json

Return: VSearchResult

Inputs

Field Type Description
offset int pagination offset
max int pagination record count

Reprocess file

Perform a full reprocess of this file

GET https://whats.todaysplan.com.au/rest/files/reprocess/{id:.+}

Return content type: application/json

Return: VFileIndex

Premium analytics

Inputs

Field Type Description
ID long The file ID

Reprocess file

Perform a full reprocess of this file, with alternate input metrics

POST https://whats.todaysplan.com.au/rest/files/reprocess/{id:.+}

Input content type: application/json

Return content type: application/json

Return: VFileIndex

Premium analytics

Inputs

Field Type Description
ID long The file ID
input DataFileUploadContext Alternate input params to be used

Reprocess file

Reprocess all files within this timestamp range using the given input params

POST https://whats.todaysplan.com.au/rest/files/reprocess/{startts:.+}/{endts:.+}

Input content type: application/json

Return content type: application/json

Return: boolean

Premium analytics

Inputs

Field Type Description
start ts long timestamp to start search from
end ts long timestamp to finish search at
input DataFileUploadContext input params to use when processing these files

Restore file

Restore a file to it’s original data file

GET https://whats.todaysplan.com.au/rest/files//channel/restore/{id:.+}

Return content type: application/json

Return: VFileIndex

Premium analytics

Inputs

Field Type Description
ID Long The file ID

Search for user workout files

POST https://whats.todaysplan.com.au/rest/files//search/{offset:.+}/{max:.+}

Input content type: application/json

Return content type: application/json

Return: VSearchResult<VUserWorkoutFile>

Inputs

Field Type Description
input VUserWorkoutFileSearch The search criteria
offset int pagination offset
max int pagination record count

Supported

Get a list of supported file extensions

GET https://whats.todaysplan.com.au/rest/files//supports

Return content type: application/json

Return: List<DataFileType>

API - File upload

Upload an activity file

Request

{
  "filename": "andrew-hall-20150823083057.fit",
  "activityType": "workouts",
  "activityId": 100045,
  "name": "Northside HOP",
  "thresholdWatts": 350,
  "equipment": "mtb",
  "workout": "training",
  "weight": 70.1
}

Response

{
  "id": 6234544,
  "resultId": 6234545,
  "filename": "andrew-hall-20150823083057.fit",
  "state": "finished",
  "type": "data",
  "result": {
    "id": 6234545,
    "workoutId": 100045,
    "activityId": 6234495,
    "activityType": "workouts",
    "url": "https://whats.todaysplan.com.au/calendar/workouts/6234495"
  }
}

POST https://whats.todaysplan.com.au/rest/files/upload

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
attachment The file content / input stream
json { filename: “20150823083057.fit” } The associated metadata object - see below

Metadata / Json Parameters

Field Required Type Description
filename yes String The filename
activityType no ActivityResultType Force this file to be associated with a given event or workout
activityId no Long Force this file to be associated with a given event or workout
name no String Alternate name for a ride - ie Northside HOP
thresholdWatts no Integer Alternate threshold power (watts) to be used when processing this file
equipment no Equipment Equipment type used for this ride
workout no WorkoutType Type of ride
weight no Double Rider weight (kg) to be used when processing this ride

The response will contain a status on the processing of this file. Usually, it will return with a pending state, meaning the file has been queued for processing.

If the file has been processed or an attempt is made to upload a duplicate file, then details of the processed file are included - such as the file’s id and URL.

The id field in this response can be used to check for the processing status of the file. It can also be used to reprocess a file at a later date.

API - Companies

Introduction

{
  "id": 6234838,
  "name": "ACME Promotor",
  "url": "http://www.acmeco.com.au",
  "bannerUrl": "https://s3.com/company/6234838/2015/08/27/tplogo.jpeg",
  "isPromotor": true,
  "isTeam": false,
  "isManufacturer": false,
  "permissions": [
    "edit1",
    "edit2",
    "edit3"
  ],
  "isPrimary": false
}

The company record is used for a number of purposes within Today’s Plan. Including;

The following fields can be viewed on a company record;

Field Description
permissions This is a collection of permissions that the current has has on the company. The permission set can be controlled via the CompanyUser object
bannerUrl This will be a publically accessible URL where the company’s banner image can be accessed.

Add company

Request

{
  "name": "ACME Promotor",
  "url": "http://www.acmeco.com.au",
  "descr": "This is a sample event promotor company",
  "isCoach": false,
  "isPromotor": true,
  "isPrimary": false
}

Response

{
  "id": 6234838,
  "name": "ACME Promotor",
  "url": "http://www.acmeco.com.au",
  "isPromotor": true,
  "isTeam": false,
  "isManufacturer": false,
  "permissions": [
    "edit1",
    "edit2",
    "edit3"
  ],
  "isPrimary": false
}

POST https://whats.todaysplan.com.au/rest/companies/add

Content Type: application/json

The following fields can be set on a company record;

Field Required Type Description
name yes String This is the name of the company
url no String A URL for the company
descr no String A description which describes the company
isCoach no Boolean A flag indicating if this company is a coaching company (default = false)
isPromotor no Boolean A flag indicating if this company is an event promotor company (default = false)
isPrimary no Boolean A flag indicating if this company is the user’s primary company (default = true if this is the first company being added to the user’s account)

Edit company

Request

{
  "name": "ACME Promotor v2"
}

POST https://whats.todaysplan.com.au/rest/companies/set/<company.id>

Content Type: application/json

Get company by id

Response

{
  "id": 6234838,
  "name": "ACME Promotor",
  "url": "http://www.acmeco.com.au",
  "bannerUrl": "https://s3.com/company/6234838/2015/08/27/tplogo.jpeg",
  "isPromotor": true,
  "isTeam": false,
  "isManufacturer": false,
  "permissions": [
    "edit1",
    "edit2",
    "edit3"
  ],
  "isPrimary": false
}

GET https://whats.todaysplan.com.au/rest/companies/get/<company.id>

Find company

Request

{
  "name": "ACME Promotor"
}

Response

{
  "cnt": 1,
  "offset": 0,
  "results": [
    {
      "id": 6234838,
      "name": "ACME Promotor"
    }
  ]
}

POST https://whats.todaysplan.com.au/rest/companies/search/<offset>/<count>

Content Type: application/json

Search paramaters

Field Type Description
name String Find all companies who have a name which contains this name. ie like %name%
isCoach Boolean Only search for companies which have isCoach set to true or false
isPromotor Boolean Only search for companies which have isPromotor set to true or false

URL paramaters

Field Description
offset The pagination offset to start returning results from
count The number of results to return from the offset onwards

To get the next set of paginated results use;

GET https://whats.todaysplan.com.au/rest/companies/next/<offset>/<count>

POST https://whats.todaysplan.com.au/rest/companies/upload/<company.id>

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
attachment The file content / input stream
filename logo.jpg The filename. This will be exposed in the URL provided to access this image

API - Events

Introduction

{
  "id": 6234813,
  "name": "My big event",
  "ts": 1440669871832,
  "_ts-dst": true,
  "_ts-display": "28/01/16",
  "_ts-tz": "Australia/Sydney",
  "media": "http://someyoutubelink.com",
  "bannerUrl": "https://s3.com/company/6234779/2015/08/27/tplogo.jpeg",
  "descr": "This is a massive 100km race",
  "isStage": false,
  "isSeries": false,
  "company": {
    "id": 6234779,
    "name": "ACME"
  },
  "courses": [
    {
      "id": 6234814,
      "eventId": 6234813,
      "eventName": "My big event",
      "venue": {
        "id": 6234811,
        "name": "Majura Pines - New",
        "address": "Federal Hwy",
        "url": "http://www.majurapines.act.gov.au",
        "lat": -35.239188,
        "lon": 149.193666,
        "country": "Australia",
        "state": "Australian Capital Territory"
      },
      "name": "My 100km",
      "type": "xc",
      "_type-display": "XC",
      "media": "http://someyoutubelink.com",
      "ts": 1440669871832,
      "_ts-dst": true,
      "_ts-display": "28/01/16 9:00 AM",
      "_ts-tz": "Australia/Sydney",
      "distance": 10000,
      "_distance-display": "10.0 km",
      "duration": 14400,
      "_duration-display": "4h",
      "categories": [
        "two",
        "one"
      ]
    }
  ],
  "planBuilderAvailable": false
}

The event record is used for a adding races and events to the system.

Users of the system can add these event’s to their calendar, and in most cases they can also build a training plan from the event.

The basic model for the event is that the event has 1 or more courses.

If the event is a stage race, then each day would have a course entry.

If the event is a series races, then each race in the series would have a course entry.

For single day races, multiple courses are possible - ie there is a 50km and 100km option.

The following sequence should be used for creating events;

Add event

Add event

{
  "id": 6234813,
  "name": "Solo 24hr Nationals",
  "ts": 1440652950559,
  "media": "http://someyoutubelink.com",
  "descr": "This is my event description which could be in HTML markup",
  "isStage": false,
  "isSeries": false,
  "company": {
    "id": 6234779
  }
}

POST https://whats.todaysplan.com.au/rest/events/add

Content Type: application/json

The following fields can be set on an event record;

Field Required Type Description
name yes String This is the name of the event
ts yes timestamp Timestamp for when this event starts. If this is a stage race or series, this is the date of the first stage/round
media no String A external media URL - ie a youtube link
descr yes String A description of the event. This can be in HTML markup
isStage no Boolean If true, this event will be treated as a Stage race
isSeries no Boolean If true, this event will be treated as a multirace series
url no String The event’s website URL
company.id yes Long The company that this event is associated with

Add venue

Add venue

{
  "name": "Majura Pines - New",
  "address": "Federal Hwy",
  "url": "http://www.majurapines.act.gov.au",
  "lat": -35.239188,
  "lon": 149.193666,
  "country": "Australia",
   "state": "Australian Capital Territory"
}

POST https://whats.todaysplan.com.au/rest/venues/add

Content Type: application/json

The following fields can be set on a course’s venue;

Field Required Type Description
name yes String This is the name of the venue - ie Stromlo Forest Park
address no String A street address of the venue
url no String A URL relevant to this venue
lat no Double The latitude of the event venue
lon no Double The longitude of the event venue
country no String The country where the venue is
state no String The state or county where the venue is

Add course

A course can be added to an event once you have created an event and you have a venue for your course.

Add course

{
  "event": {
    "id": 6234813
  },
  "course": {
    "venue": {
      "id": 6234811
    },
    "type": "xc",
    "name": "My 100km",
    "descr": "This is a description of my course which could be in HTML markup",
    "distance": 10000,
    "ascent": 2500,
    "descent": 2500,
    "media": "http://someyoutubelink.com"
  },
  "ts": 1453932000000,
  "categories": [
    "two",
    "one"
  ]
}

POST https://whats.todaysplan.com.au/rest/eventcourses/add

Content Type: application/json

The following fields can be set on a course’s associated with the event;

Field Required Type Description
name yes String This is the name of the course - ie 100km course
type yes EventType This is the type of event. ie mountain bike, road, enduro etc
media no String A external media URL - ie a youtube link
ts yes timestamp Timestamp of when this race starts. ie 9am race start for the 100km
distance no Integer Distance in meters (ie 100km race)
duration no Integer Duration in seconds (ie 8hr enduro)
categories yes EventCategory A collection of categories which are applicable to the event. ie solo, two, three etc team option
venue.id yes Long The venue that this course is associated with
event.id yes Long The event that this course is associated with

Edit event

Edit event

{
  "name": "A new name and time for the event",
  "ts": 1440652950559
}

POST https://whats.todaysplan.com.au/rest/events/set/<event.id>

Content Type: application/json

Edit venue

Edit venue

{
  "name": "A new name for my venue"
}

POST https://whats.todaysplan.com.au/rest/venues/set/<venue.id>

Content Type: application/json

Edit course

Edit course

{
  "name": "A new name for my course"
}

POST https://whats.todaysplan.com.au/rest/eventcourses/set/<course.id>

Content Type: application/json

Get event by id

GET https://whats.todaysplan.com.au/rest/events/get/<event.id>

GET https://whats.todaysplan.com.au/rest/events/get/detailed/<event.id>

Get venue by id

GET https://whats.todaysplan.com.au/rest/venues/get/<venue.id>

GET https://whats.todaysplan.com.au/rest/venues/get/detailed/<venue.id>

Get course by id

GET https://whats.todaysplan.com.au/rest/eventcourses/get/<course.id>

GET https://whats.todaysplan.com.au/rest/eventcourses/get/detailed/<course.id>

Find event

Find event

{
  "name": "Solo 24hr Nationals",
   "fromTs": 1440652950559
}

Event search response

{
  "cnt": 1,
  "offset": 0,
  "results": [
    {
      "id": 6234813,
      "cls": "event",
      "name": "Solo 24hr Nationals"
    }
  ]
}

POST https://whats.todaysplan.com.au/rest/events/search/<offset>/<count>

Content Type: application/json

Search paramaters

Field Type Description
name String Find all events who have a name which contains this name. ie like %name%
events EventType A collection of event types to search for. ie find all road and mtb events
within Integer Restrict search results to events which X km of me
fromTs timestamp Restrict search to events which start after this date
toTs timestamp Restrict search to events which start before this date
companyIds Long Restrict search to events related to the given company id’s (collection of ids

As per venue table above

URL paramaters

Field Description
offset The pagination offset to start returning results from
count The number of results to return from the offset onwards

To get the next set of paginated results use;

GET https://whats.todaysplan.com.au/rest/events/next/<offset>/<count>

Find venue

Find venue

{
  "name": "Majura Pines - New"
}

Venue search response

{
  "cnt": 1,
  "offset": 0,
  "results": [
    {
      "id": 6234811,
      "cls": "venue",
      "name": "Majura Pines - New",
      "address": "Federal Hwy",
      "url": "http://www.majurapines.act.gov.au",
      "lat": -35.239188,
      "lon": 149.193666,
      "country": "Australia",
      "state": "Australian Capital Territory"
    }
  ]
}

POST https://whats.todaysplan.com.au/rest/venues/search/<offset>/<count>

Content Type: application/json

Search paramaters

As per venue table above

URL paramaters

Field Description
offset The pagination offset to start returning results from
count The number of results to return from the offset onwards

To get the next set of paginated results use;

GET https://whats.todaysplan.com.au/rest/venues/next/<offset>/<count>

Upload event image

POST https://whats.todaysplan.com.au/rest/events/upload/<event.id>

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
attachment The file content / input stream
filename logo.jpg The filename. This will be exposed in the URL provided to access this image

Upload course route

POST https://whats.todaysplan.com.au/rest/eventcourses/upload/<course.id>

Content Type: application/x-www-form-urlencoded

Multipart Form Parameters

Field Example Description
attachment The file content / input stream
filename route.gpx The filename. This will be exposed in the URL provided to access this image

Data types - Enumerations

ActivityResultType

The type of scheduled activity

Values

Value Display Description
events Event
workouts Workout
files File

DataFileChannel

Data channels found in activity files

Values

Value Display Description
pwr Power
bpm Heart rate
rpm Cadence

DataFileType

File formats which we know how to process in different contexts

Values

Value Display Description
fit Fit Fit - a common data format for more recent Garmin and Magellan devices
ant Ant Ant - as per Fit format
gpx Gpx Gpx - a common data format for simple GPS fitness tracking devices
act Act Act - a data format used by Magellan Cyclo 105 devices
tcx Tcx Tcx - a data format used by older Garmin devices
srm Srm Srm - SRM7 data format
pwx Pwx Pwx - trainingpeaks.com native data format
json Json Json - Golden Cheetah data export format
bdx Bdx Bdx - a common data format for Bryton devices

Equipment

This enum defines different types of bikes. When an activity is recorded the type of bike used is recorded. Scheduled activities such as workouts and events may also specify a preferred bike.

Values

Value Display Description
road Road
mtb Mountain
cx Cycle-X
tt Timetrial
ss Singlespeed
commute Commuter
indoor Indoor
track Track

FileUploadState

The state of a file upload or a file reprocess

Values

Value Display Description
pending Pending File queued for processing
queued Queued File queued for processing
processing Crunching File is currently being processed
finished Finished File successfully uploaded!
error Error File could not be processed at this time

FileUploadType

The type of file being uploaded

Values

Value Display Description
data Activity file
course Route file
weight Weight file

WorkoutType

The type of activity which has been completed or scheduled.

Values

Value Display Description
training Training
event Event or Race
test Threshold Test
rest Rest or Recovery

Data types - Objects

DataFileUploadContext

DataFileUploadContext - Metadata used on data file uploads and reprocessing

Values

Value Display Description
userId userId The user id who this file belongs to
age age Rider age in years
gender gender Rider gender
filename filename The original filename
activityType Activity type The activity type this file is to be associate with
activityId activityId The activity id this file is to be associated with
name name Alternate display name
thresholdWatts power threshold The threshold (watts) to be used when processing this file
thresholdBpm bpm threshold The threshold (BPM) to be used when processing this file
equipment equipment The equipment used for this activity
workout workout The workout type for this activity
weight weight The rider weight in kg to be used when processing this file

VUserWorkoutFile

UserWorkoutFile - A data object used to display metadata about recorded activity files

Values

Value Display Description
id ID The activity file’s unique system id
activityId Activity ID The ID of the activity which this file is associated with. ie an event or a workout
activityType Activity Type The type of the activity which this file is associated with. ie an event or a workout
ts Timestamp The timestamp for this file. This will either be the start time of the activity, of the time of the scheduled event/workout
filename Filename The original filename
name Name An alternate name for the file
user User The user that this file belongs to
url URL The URL to this activity
index Index The file processing index. Holds the state of the file when it is being processed

VFileIndex

FileIndex - Metadata about the state of a file upload and processing

Values

Value Display Description
id ID A unique system ID for this file upload
resultId ResultID The ID of the resulting object which is created from this file upload
ts Timestamp Time of when the file was recieved or last reprocessed
filename Filename The original filename of the uploaded file
state State The current file processing state
states States A collection of FileUploadStates - can be set in a search criteria
type Type The type of file being processed
message Message System message relating to the file processing
result Result The resulting object which was created from this file upload
user User The user who this file belongs to

VSearchResult

SearchResult - A result object for when a search has been performed

Values

Value Display Description
cnt Count The total number of records which matched this search query
offset Offset The offset where the paginated results were returned from
results Results The paginated result set

VUserWorkoutFileSearch

Search - User workout file search options

Values

Value Display Description
name Name Search result names or filenames - matches on a contains query
fromTs From TS Search for files with a start ts >= X
toTs To TS Search for files with a start ts <= X
maxWatts Max Watts Search for files with a max watts >= X
maxBpm Max BPM Search for files with a max bpm >= X
maxRpm Max RPM Search for files with a max rpm >= X
user User Search for files related to the given user
group Group Search for files related to the given group

Sample code - Java

Sample GET request

Sample GET request

CloseableHttpClient client; 

String url = "https://whats.todaysplan.com.au/rest/auth/whoami";

HttpGet get = new HttpGet(url);
CloseableHttpResponse rsp = null;
try {

  if (token != null)
    get.addHeader("Authorization", "Bearer " + token);

  rsp = client.execute(get);

  String js = IOUtils.toString(rsp.getEntity().getContent());

  ...

} finally {
  if (rsp != null)
    rsp.close();

  get.releaseConnection();
}

Sample POST request

Sample POST request

CloseableHttpClient client; 

String url = "https://whats.todaysplan.com.au/rest/auth/login";
Map<String,String> input = new HashMap<String,String();
input.put("username", "andrew@todaysplan.com.au");
input.put("password", "secretstuff");

HttpPost post = new HttpPost(url);
CloseableHttpResponse rsp = null;
try {

  StringEntity js = new StringEntity(Json.toJson(input));
  post.addHeader("content-type", "application/json");
  post.setEntity(js);

  if (token != null)
    post.addHeader("Authorization", "Bearer " + token);

  rsp = client.execute(post);

  String js = IOUtils.toString(rsp.getEntity().getContent());

  ...

} finally {
  if (rsp != null)
    rsp.close();

  post.releaseConnection();
}

Sample file upload

Sample file upload

CloseableHttpClient client; 
File file;
Map<String,String> entity;

String url = "https://whats.todaysplan.com.au/rest/files/upload";

HttpPost post = new HttpPost(url);
CloseableHttpResponse rsp = null;
try {

  MultipartEntityBuilder builder = MultipartEntityBuilder.create();
  builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

  FileBody fileBody = new FileBody(file);
  builder.addPart("attachment", fileBody);
  builder.addTextBody("filename", file.getName());

  if (entity != null)
    builder.addTextBody("json", Json.toJson(entity));

  post.setEntity(builder.build());

  if (token != null)
    post.addHeader("Authorization", "Bearer " + token);

  rsp = client.execute(post);

  String js = IOUtils.toString(rsp.getEntity().getContent());

  ...

} finally {
  if (rsp != null)
    rsp.close();

  post.releaseConnection();
}