Fitness Trackr (1.1.0)

Fitness Trackr is a platform where fitness enthusiasts can share their workouts and discover new routines. Anyone can browse the site and make an account, and users with an account will be able to upload and manage their own activities.

API Usage

The URL to access a resource from this API is structured as follows:

  • The base URL is https://fitnesstrac-kr.herokuapp.com/api
  • The next segment is based on the resource you want to access e.g. /activities

For example, the URL for all activities would be:

https://fitnesstrac-kr.herokuapp.com/api/activities

Authentication

When using the API, many calls are made in the context of a registered user. The API protects itself by requiring a token string passed in the header for requests made in that context.

The Authorization header should be a string with the format Bearer token; the token is received either by registering or logging in. Deviating from this format will cause the API to not recognize the token and will result in an error.

If the token is malformed, missing, or has been revoked, you will get a response specific to that.

Users

Users need an account in order to access many of the endpoints on this API.

Register

Request Body schema: application/json
required
username
required
string

the username of the user

password
required
string

the password of the user

Responses

Response Schema: application/json
object
message
string

the success message

token
string

the JSON Web Token used to authenticate the user for any future requests

Request samples

Content type
application/json
{
  • "username": "superman27",
  • "password": "krypt0n0rbust"
}

Response samples

Content type
application/json
{
  • "user": {
    },
  • "message": "Success!",
  • "token": "abcdefghijklmnopqrstuvwxyz"
}

Login

Request Body schema: application/json
required
username
required
string

the username of the user

password
required
string

the password of the user

Responses

Response Schema: application/json
object
message
string

the success message

token
string

the JSON Web Token used to authenticate the user for any future requests

Request samples

Content type
application/json
{
  • "username": "superman27",
  • "password": "krypt0n0rbust"
}

Response samples

Content type
application/json
{
  • "user": {
    },
  • "message": "Success!",
  • "token": "abcdefghijklmnopqrstuvwxyz"
}

Activities

An activity is an task, action, or exercise.

Get all activities

Responses

Response Schema: application/json
Array
name
string

the name or title of the activity

description
string

the description of the activity

id
number

the database identifier of the activity

creatorId
number

the database identifier of the user who created this activity

Response samples

Content type
application/json
[
  • {
    }
]

Create new activity

A valid token must be passed with this request or it will be rejected.

Authorizations:
token
Request Body schema: application/json
required
name
required
string

the name or title of the activity

description
required
string

the description of the activity

Responses

Response Schema: application/json
name
string

the name or title of the activity

description
string

the description of the activity

id
number

the database identifier of the activity

creatorId
number

the database identifier of the user who created this activity

Request samples

Content type
application/json
{
  • "name": "Incline Dumbbell Hammer Curl",
  • "description": "Lie down face up on an incline bench and lift the barbells slowly upward toward chest"
}

Response samples

Content type
application/json
{
  • "name": "Incline Dumbbell Hammer Curl",
  • "description": "Lie down face up on an incline bench and lift the barbells slowly upward toward chest",
  • "id": 1,
  • "creatorId": 9
}

Get a single activity

path Parameters
id
required
number
Example: 123

the ID of the activity to get

Responses

Response Schema: application/json
name
string

the name or title of the activity

description
string

the description of the activity

id
number

the database identifier of the activity

creatorId
number

the database identifier of the user who created this activity

creatorName
string

the name of the user who created this activity

Response samples

Content type
application/json
{
  • "name": "Incline Dumbbell Hammer Curl",
  • "description": "Lie down face up on an incline bench and lift the barbells slowly upward toward chest",
  • "id": 1,
  • "creatorId": 9,
  • "creatorName": "Albert"
}

Delete an activity

A valid token must be passed with this request or it will be rejected. Furthermore, that token must represent the user who created this activity.

Authorizations:
token
path Parameters
id
required
number
Example: 123

the ID of the activity to remove

Responses

Routines

A routine is a named collection of different activities.

Get all routines

Responses

Response Schema: application/json
Array
id
number

the database identifier of the routine

name
string

the name or title of the routine

goal
string

the fitness goal of the routine

creatorId
number

ID of the user who created the routine

creatorName
string

name of the user who created the routine

Array of objects

the sets of activities to perform in this routine

Response samples

Content type
application/json
[
  • {
    }
]

Create new routine

A valid token must be passed with this request or it will be rejected.

Authorizations:
token
Request Body schema: application/json
required
name
required
string

the name or title of the routine

goal
required
string

the fitness goal of the routine

Responses

Request samples

Content type
application/json
{
  • "name": "Chest Day",
  • "goal": "to beef up the chest and triceps!"
}

Response samples

Content type
application/json
{
  • "id": 85,
  • "name": "Chest Day",
  • "goal": "to beef up the chest and triceps!",
  • "creatorId": 1,
  • "creatorName": "Albert"
}

Delete a routine

A valid token must be passed with this request or it will be rejected. Furthermore, that token must represent the user who created this routine.

Authorizations:
token
path Parameters
id
required
number
Example: 123

the ID of the routine to remove

Responses

Sets

A set is an activity repeated for a certain number of times.

Add set to routine

A valid token must be passed with this request or it will be rejected. Furthermore, that token must represent the user who created the routine.

Authorizations:
token
Request Body schema: application/json
required
activityId
required
number

the ID of the activity to perform in this set

routineId
required
number

the ID of the routine this set belongs to

count
required
number

the number of reps to perform the activity in this set

Responses

Request samples

Content type
application/json
{
  • "activityId": 1,
  • "routineId": 85,
  • "count": 8
}

Response samples

Content type
application/json
{
  • "activityId": 1,
  • "routineId": 85,
  • "count": 8,
  • "id": 29
}

Delete a set from a routine

A valid token must be passed with this request or it will be rejected. Furthermore, that token must represent the user who created the routine.

Authorizations:
token
path Parameters
id
required
number
Example: 29

the ID of the set to remove

Responses