samosa documentation - read the docs · samosa documentation, release alpha release samosa helps...

21
Samosa Documentation Release Alpha Release Balaji Iyer, Sriram Vasudevan Sep 27, 2017

Upload: others

Post on 26-Oct-2019

74 views

Category:

Documents


0 download

TRANSCRIPT

Samosa DocumentationRelease Alpha Release

Balaji Iyer, Sriram Vasudevan

Sep 27, 2017

Contents

1 Features 3

2 Samosa Components 5

3 Samosa Bot 7

4 API 9

5 UI 11

6 Contribute 13

7 Support 15

8 License 17

i

ii

Samosa Documentation, Release Alpha Release

Samosa helps you build leaderboards for various fitness devices, allowing you to compete with your friends.

Currently it supports:

• Jawbone Up

• Fitbit

Feature revisions could include -

• Garmin Vivofit

• Polar Loop

• Argus Lifetrak

• Nike Plus

Contents 1

Samosa Documentation, Release Alpha Release

2 Contents

CHAPTER 1

Features

• Easy to use API

• Support for many popular devices

3

Samosa Documentation, Release Alpha Release

4 Chapter 1. Features

CHAPTER 2

Samosa Components

5

Samosa Documentation, Release Alpha Release

6 Chapter 2. Samosa Components

CHAPTER 3

Samosa Bot

Samosa bot is resposible for collecting activities and stats from different APIs and storing it in Redis. The bot runsevery 30 mins. (Configurable)

7

Samosa Documentation, Release Alpha Release

8 Chapter 3. Samosa Bot

CHAPTER 4

API

1. Add user details to Samosa

Typical details include the type of product they are using, and credentials that would help pull data on user’s behalffrom device provider’s API

POST /user

Content-Type: application/json

{"name" : "Balaji Iyer","device" : {fitbit,vivofit,up,nikeplus,argus},"credentials" : apikey, {username, password}, customer secret}

Example for fitbit:

Content-Type: application/json

{"credentials": {"client_key": "xx"client_secret": "xx","resource_owner_key": "xx","resource_owner_secret": "xx"},

"device": "fitbit","name": "balaji"}

Example for jawbone-up:

Content-Type: application/json

{

9

Samosa Documentation, Release Alpha Release

"credentials": {"Authorization": "Bearer xx},"device": "jawbone-up","name": "Obul"

}

2. Get leaderboard

GET /leaderboard

[{

"user": "sriram","rank": 1,"data": { "steps":100, "calories": 200, "distance": 2.8 },"rankingmetric": "steps"

},{

"user": "balaji","rank": 2,"data": { "steps":80, "calories": 200, "distance": 2.8 },"rankingmetric": "steps"

}]

By default, users will be ranked by steps, however the default ranking can be changed→˓by passing a 'rankby' parameter.

GET /leaderboard?rankby={steps,calories,distance}

3. Get stats on a specific user

GET /stats?user={username}

{"user": "sriram","rank": 1,"data": { "steps":100, "calories": 200, "distance": 2.8 },"rankingmetric": "steps"

}

10 Chapter 4. API

CHAPTER 5

UI

Samosa prints a leaderboard by making an AJAX request to the API. Check ui/leaderboard.html for the source.

11

Samosa Documentation, Release Alpha Release

12 Chapter 5. UI

CHAPTER 6

Contribute

• Issue Tracker: github.com/balajiiyer/samosa/issues

• Source Code: github.com/balajiiyer/samosa

13

Samosa Documentation, Release Alpha Release

14 Chapter 6. Contribute

CHAPTER 7

Support

If you are having issues, please let us know using the github Issue Tracker.

15

Samosa Documentation, Release Alpha Release

16 Chapter 7. Support

CHAPTER 8

License

The project is licensed under the GPL v2 license.

17