mrthn (pronounced marathon) is a service that allows you to aggregate the data from multiple Fitness App APIs into simple endpoints. Currently, it supports Google Fitness, Strava, and Fitbit.
To run this project, you will need to set some environment values. To assist you, duplicate the .env.example
file, rename it to .env
and set the values within.
For integration testing, you only need to set DB_CONNECTION_STRING
.
This string should point to an instance of PostgreSQL and to the public
database. It also needs to set sslmode
to disable
postgresql://user:secret@localhost/public?sslmode=disable
or
host=localhost dbname=public user=user sslmode=disable
To allow your instance of mrthn to authenticate with the supported Fitness platforms, you will need to create developer accounts with each of them and generate OAuth2 credentials.
Explanation for other environment variables coming soon...
To run this service or its integration tests, you will need to set up a db instance
- Have a PostgreSQL server set up. Note that mrthn will clear your
public
database. - Run
db/db_create.sql
anddb/user_data.sql
in your PostgreSQL instance. Example:
psql -a postgresql://user:secret@localhost/public -f db/user_data.sql)
- You're all set!
- Clone the project
# run this command within $GOPATH/src/github.com/msgurgel/
git clone https://github.com/msgurgel/mrthn.git
- Go to the project directory
cd mrthn
- Install dependencies
go get ./...
-
Set environment variables. See Environment Variables section.
-
Set up your database. See Database Set Up section.
-
Compile the code
go build ./cmd/mrthn
- Run the executable
./mrthn --log-to-stderr
To run unit tests, run the following command
go test ./...
To run the integration tests, you will need to do some setup first:
See Database Set Up section.
sandwich
is a small ruby app that runs the integration tests (see README). To install its depencies, run the following command inside of integration/sandwich
and integration/sandwich/server
bundle install
See Environment Variables section.
Finally, run the integration test script from the project's home directory
# in $GOPATH/src/github.com/msgurgel/mrthn
./integration/integration-test.sh
If anything goes wrong, you can check the log/
directory for more information.
GET /
GET /user/${userId}/calories/daily?date=${date}
Path Parameter | Type | Description |
---|---|---|
userId |
integer |
Required. Id of the user to fetch data from |
Query Parameter | Type | Description |
---|---|---|
date |
date |
Required. Day to get data from. Format is YYYY-MM-DD |
largestOnly |
bool |
Set to true to return data from only the platform with the largest value |
GET /user/${userId}/steps/daily?date=${date}
Path Parameter | Type | Description |
---|---|---|
userId |
integer |
Required. Id of the user to fetch data from |
Query Parameter | Type | Description |
---|---|---|
date |
date |
Required. Day to get data from. Format is YYYY-MM-DD |
largestOnly |
bool |
Set to true to return data from only the platform with the largest value |
GET /user/${userId}/steps/distance?date=${date}
Path Parameter | Type | Description |
---|---|---|
userId |
integer |
Required. Id of the user to fetch data from |
Query Parameter | Type | Description |
---|---|---|
date |
date |
Required. Day to get data from. Format is YYYY-MM-DD |
largestOnly |
bool |
Set to true to return data from only the platform with the largest value |
GET /user/${userId}/distance/over-period?period=${period}
Path Parameter | Type | Description |
---|---|---|
userId |
integer |
Required. Id of the user to fetch data from |
Query Parameter | Type | Description |
---|---|---|
period |
period |
Required. Period of time to get data from. Possible values: "1d", "7d", "30d", "1w", "1m", "3m", "6m" |
Will add this section soon! 🔜
If you have any feedback or questions, please reach out to me at me@magu.dev