everydayhero: Developer

Fitness Activities

Pages can have fitness activities associated with them. Complementary to fitness activities synced from within the application (e.g. Strava, MapMyFitness), applications can create their own activities.

Example activity on a supporter page:

Authorization Screen

Retreive a list of Fitness Activities

GET https://everydayhero.com/api/v2/search/fitness_activities

Parameters

charity_id : optional string or Array
Charity ID, only totals for that the specified Charity will be retrieved. An Array of IDs can be provided, eg: charity_id[]=au-1&charity_id[]=au-2

campaign_id : optional string or Array
Campaign ID, only totals for that the specified Campaign will be retrieved. An Array of IDs can be provided, eg: campaign_id[]=au-1&campaign_id[]=au-2

page_id : optional string or Array
Page ID, only totals for the specified Pages will be retrieved. An Array of IDs can be provided, eg: page_id[]=111&page_id[]=456

team_id : optional string
team_uid : optional string
team_page_id : optional string
Team ID, only totals for that the specified Team will be retrieved.

start_at : optional string/date-time
Start at date, ISO format: “2014-08-20 05:02:13”, filter totals by a range.

end_at : optional string/date-time
End at date, ISO format: “2014-08-20 05:02:13”, filter totals by a range.

type : optional string
Filter by activity type: e.g. bike, gym, hike, run, sport, swim, walk

include_manual : optional boolean
Include manually entered activities. Default: false.

exclude_virtual : optional boolean
Exclude virtual activities. Default: false

exclude_non_virtual : optional boolean
Exclude non-virtual activities. Default: false

Pagination

For more information about pagination, please see the pagination overview.

limit : optional integer
The number of items per page.

page : optional integer
The page number to return.

Example

https://everydayhero.com/api/v2/search/fitness_activities.json?campaign_id=au-0

Response

{
  "fitness_activities": [
    {
      "id": 13342,
      "uid": "trailyoursteps-3476623",
      "page_id": 297062,
      "team_id": 24093,
      "charity_uid": "au-599",
      "campaign_uid": "au-0",
      "type": "bike",
      "virtual": true,
      "manual": false,
      "trainer": false,
      "flagged": false,
      "public": true,
      "deleted": false,
      "started_at": "2015-10-27T01:32:25.000Z",
      "coordinate": {
        "lat": 37.54106,
        "lon": -77.4341
      },
      "distance_in_meters": 10107,
      "elevation_in_meters": 12,
      "calories": 273,
      "duration_in_seconds": 957,
      "caption": "Lunch Ride",
      "_score": null,
      "_type": "fitness_activity",
      "_sort": [
        1445909545000
      ]
    }
  ]
}

Create/Update Fitness Activity

Authentication types: OAuth User Token only

POST https://everydayhero.com/api/v2/fitness_activities

Parameters

uid : required string
Unique identifier to fitness activity, to be used later for updating activities if required.

type : required string
Fitness activity type, supported types: bike, gym, hike, run, swim, walk and sport.

duration_in_seconds : required integer
Duration of activity, in seconds.

manual : optional boolean
Manually logged activity, should be true if this manually user created activity, false if it is logged via an application.

virtual : optional boolean
Virtually logged activity, should be true if this is via a virtual app, eg Zwift, false for most cases.

trainer : optional boolean
Trainer logged activity, should be true if this is via a cycling turbo trainer, false for most cases.

public : required boolean
Must be true for the fitness activity to be visible.

started_at : required date/time
Timestamp for start of activity, ISO8601 format.

caption : required string
Title/caption for activity.

distance_in_meters : optional integer
Distance covered for activity, in meters.

distance : optional integer
Distance covered for activity, in any distance format. Requires unit attributes to be sent

unit : optional string
Unit for distance, e.g.: meter, foot, step, yard, mile, km. Requires distance attribute to be sent.

calories : optional integer
kcals total burned per activity, e.g. ~600 for a 10km run.

coordinates : optional Array
To be used to render a map, if provided. Array of lat/longs,
e.g. [[10.614, -7.031],[10.612, -7.027],[10.609, -7.020]..]

elevation_series : optional Array
Array of elevation points (in meters), used to render an elevation chart if provided.
e.g. [0.2, 0.8, 1.2, 5.6]

average_watts : optional integer
Average power output for an activity (normally a ‘bike’ activity).

average_heartrate : optional integer
Average heart rate in bpm for an activity.

average_cadence : optional integer
Average cadence in rpm for an activity (normally a ‘bike’ activity).

average_temp : optional integer
Average external temperature in degrees celcius for an activity.

description : optional string
Description of an activity.

Example

curl -H "Authorization: Bearer XXX" \
-d "{\"uid\":\"abc\",\"type\":\"bike\",\"duration_in_seconds\":1234,\"public\":true,\"started_at\":\"2015-01-01 09:00:00\",\"distance_in_meters\":1234,\"calories\":100,\"coordinates\":[[10.614,-7.031],[10.612,-7.027],[10.609,-7.02]],\"elevation_series\":[0.2,0.8,1.2,5.6],\"caption\":\"test-ride\"}" \
https://everydayhero.com/api/v2/fitness_activities.json

Response

201 CREATED

or

422 Unprocessable Entity

{
  "error": {
    "message": "Validation failed",
    "error": [
      {
        "field": "type",
        "code": "invalid"
      }
    ]
  }
}