Endpoint
GET https://api.misfitwearables.com/auth/dialog/authorize
Description
Authorize a 3rd-party app to access a user’s data. There will be two types of responses depending on the response_type: either an access token which represents the user or code which the 3-rd party app can exchange for an access token.
Request
Query string parameters
parameter | type | optional | description |
---|---|---|---|
response_type | string | No | either code or token. Read here for more detail |
client_id | string | No | 3rd-party app id that was provided via Web Portal |
redirect_uri | string | No | 3rd-party server callback URI to receive user’s authorization result. |
scope | string | No | list of permissions, for example: public,birthday,email,tracking,session,sleeps. Scope is a place-holder for now. Just use ‘public,birthday,email’,which will get full permission. |
Note
Response
Redirect to redirect_uri with the following querystring parameter:
parameter | type | optional | description |
---|---|---|---|
access_token | string | No | the access token that represents the current user |
or
parameter | type | optional | description |
---|---|---|---|
code | string | No | the code that verifies the previous authentication. 3rd party app need to exchange this code for an access token using the below API |
Endpoint
POST https://api.misfitwearables.com/auth/tokens/exchange
Description
API for exchanging the authentication code for an access token
Request Body
parameter | type | optional | description |
---|---|---|---|
grant_type | string | No | only ‘authorization_code’ for now |
code | string | No | the code that the user received from /dialog/authorize |
redirect_uri | string | No | 3rd-party server callback URI to receive user’s access_token. Must be the same as previous API’s redirect_uri. |
client_id | string | No | 3rd-party app id that was provided via Web Portal |
client_secret | string | No | 3rd-party app secret that was provided via Web Portal |
Response
parameter | type | optional | description |
---|---|---|---|
access_token | string | No | access_token that represent the user |
token_type | string | No | token’s type:bearer |
Example
JSON:
POST /auth/tokens/exchange HTTP/1.1
Host: api.misfitwearables.com
Content-Type: application/json
{
"grant_type": "authorization_code",
"code": "the code",
"client_id": "your app id",
"client_secret": "your app secret",
"redirect_uri": "http://match_your_application_domain_setting"
}
HTTP Status: 200
{
"access_token":"afwfh384hg84uh348g34g8374hga874gh8a374gha8347gha8347",
"token_type":"bearer"
}
Form URLEncoded:
POST /auth/tokens/exchange HTTP/1.1
Host: api.misfitwearables.com
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=the_code&client_id=your_app_id&client_secret=your_app_secret&redirect_uri=http%3A%2F%2Fmatch_your_application_domain_setting
HTTP Status: 200
{
"access_token":"afwfh384hg84uh348g34g8374hga874gh8a374gha8347gha8347",
"token_type":"bearer"
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/profile
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/profile/:ObjectId
Description
Returns the corresponding profile of a user. This API can be used to get detailed information about a particular user
Request
No request parameter is needed for this API.
Response
parameter | type | optional | description |
---|---|---|---|
userId | string | no | id of user |
name | string | no | username |
birthday | string | no | birthday of user |
gender | string | no | male / female |
avatar | string | no | avatar of user |
string | no | email of user |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/profile
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
{
"userId":"51a4189acf12e53f79000001",
"name":"Misfit",
"birthday":"1955-07-06",
"gender":"female",
"email":"help@misfit.com"//might be empty
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/device
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/device/:ObjectId
Description
Return the corresponding information of current tracker device. A user can have multiple devices, but only the current one will be returned.
Request
No request parameter is needed for this API
Response
parameter | type | optional | description |
---|---|---|---|
id | string | no | Object Id |
deviceType | string | no | type of Misfit device. For now it always returns “shine”. |
serialNumber | string | no | the device’s serial |
firmwareVersion | string | no | device’s firmware version |
batteryLevel | integer | no | 0 to 100, -1 means undefined |
lastSyncTime | integer | no | UTC timestamp, in seconds |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/device
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
{
"id":"51a4189acf12e53f80000001",
"deviceType":"shine",
"serialNumber":"XXXXXV0011",
"firmwareVersion":"0.0.50r",
"batteryLevel":40
"lastSyncTime":1433690072
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/devices
Description
Return the corresponding device’s information of all linked devices.
Request
No request parameter is needed for this API
Response
parameter | type | optional | description |
---|---|---|---|
id | string | no | Object Id |
deviceType | string | no | type of Misfit device. For now it always returns “shine”. |
serialNumber | string | no | the device’s serial |
firmwareVersion | string | no | device’s firmware version |
batteryLevel | integer | no | 0 to 100, -1 means undefined |
lastSyncTime | integer | no | UTC timestamp, in seconds |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/devices
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
[
{
"id":"51a4189acf12e53f80000001",
"deviceType":"shine",
"serialNumber":"XXXXXV0011",
"firmwareVersion":"0.0.50r",
"batteryLevel":40
"lastSyncTime":1433690072
}
]
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/goals?start_date=X&end_date=Y
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/goals/:objectId
Description
Returns the goals of a user in the period
*Note, limited to return at most 31 days; if your query covers more than 31 days you will receive an invalid parameter error.
Request
parameter | type | optional | description |
---|---|---|---|
start_date | data | no | start of the time range |
end_date | data | no | end of the time range |
Response
parameter | type | optional | description |
---|---|---|---|
id | string | no | Object Id |
date | date | no | date of that goal |
points | float | no | progress points that the user achieved that day |
targetPoints | int | no | target points for that day |
timeZoneOffset | int | no | timeZoneOffset base of ISO TIME |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/activity/goals?start_date=2013-11-05&end_date=2013-11-08
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
{
"goals":[
{
"id": "5635d123e8436c514f1375d1",
"date": "2015-11-01",
"points": 40,
"targetPoints": 1000,
"timeZoneOffset": 8
},
...
]
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/summary?start_date=X&end_date=Y&detail=true
Description
Returns the summary of a user’s activity in the period
*Note, limited to return at most 31 days; if your query covers more than 31 days you will receive an invalid parameter error.
Request
parameter | type | optional | description |
---|---|---|---|
start_date | data | no | start of the time range |
end_date | data | no | end of the time range |
detail | boolean | yes | If yes, print summary detail for each day (default is no) |
Response
parameter | type | optional | description |
---|---|---|---|
points | float | no | total points in that time range |
steps | integer | no | total steps in that time range |
calories | float | no | total calories in that time range |
activityCalories | float | no | activity-related calories in that time range |
distance | float | no | total distance travelled in that time range |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/activity/summary?start_date=2013-11-05&end_date=2013-11-08
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
{
"points": 96.4,
"steps": 888,
"calories": 3132.3888,
"activityCalories": 547.1241,
"distance": 0.2821
}
GET https://api.misfitwearables.com/move/resource/v1/user/me/activity/summary?start_date=2013-11-05&end_date=2013-11-08&detail=true
HTTP Status: 200
{
"summary": [
{
"date": "2013-11-05",
"points": 394.4,
"steps": 3650,
"calories": 1687.4735,
"activityCalories": 412.3124,
"distance": 1.18
},
{
"date": "2013-11-06",
"points": 459.6,
"steps": 4330,
"calories": 1707.8484,
"activityCalories": 412.3124,
"distance": 1.3982
},
{
"date": "2013-11-07",
"points": 430.4,
"steps": 4022,
"calories": 1698.7234,
"activityCalories": 412.3124,
"distance": 1.2988
},
{
"date": "2013-11-08",
"points": 376,
"steps": 3514,
"calories": 1681.7235,
"activityCalories": 412.3124,
"distance": 1.1429
}
]
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/sessions?start_date=X&end_date=Y
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/sessions/:object_id
Description
Returns the sessions of a user in the time range
*Note, limited to return at most 31 days; if your query covers more than 31 days you will receive an invalid parameter error.
Request
parameter | type | optional | description |
---|---|---|---|
start_data | date | no | start of the time range |
end_date | date | no | end of the time range |
:object_id | string | no | id of the object, such as “537c8c178441b21249000081” |
Response
parameter | type | optional | description |
---|---|---|---|
id | string | no | Object Id |
activityType | string | no | cycling swimming walking tennis basketball soccer |
startTime | time | no | the time the activity started |
duration | integer | no | length of the activity |
points | float | total points user gained for the activity | |
steps | integer | total steps user took for the activity | |
calories | float | total calories user burned for the activity | |
distance | float | total distance user covered for the activity, in miles |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/activity/sessions?start_date=2014-05-19&end_date=2013-05-20
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
{
"sessions":[
{
"id":"51a4189acf12e53f82000001",
"activityType":"Cycling",
"startTime":"2014-05-19T10:26:54-04:00",
"duration":900,
"points":210.8,
"steps":1406,
"calories":25.7325,
"distance":0.5125
},
...
]
}
Endpoint
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/sleeps?start_date=X&end_date=Y
GET https://api.misfitwearables.com/move/resource/v1/user/:userId/activity/sleeps/:object_id
Description
Returns the sleep sessions of a user in the time range
*Note, limited to return at most 31 days; if your query covers more than 31 days you will receive an invalid parameter error.
Request
parameter | type | optional | description |
---|---|---|---|
start_date | date | no | start of the time range |
end_date | date | no | end of the time range |
:object_id | string | no | id of the object, such as 537c8c178441b21249000081 |
Response
parameter | type | optional | description |
---|---|---|---|
id | string | no | Object Id |
autoDetected | boolean | no | was sleep auto-detected? |
startTime | time | no | time that the activity started |
duration | integer | no | duration of the sleep |
sleepDetails | array | no | array contains the details of sleep, each object in the array is as follows: |
Sleep object:
parameter | type | optional | description |
---|---|---|---|
datetime | time | no | when this section of the sleep started |
value | string | no | 1: awake 2: sleep 3: deep sleep |
Example
GET https://api.misfitwearables.com/move/resource/v1/user/me/activity/sleeps?start_date=2014-05-18&end_date=2014-05-20
Headers: {
access_token: <user_access_token>
}
HTTP Status: 200
"sleeps":[
{
"id":"51a4189acf12e53f80000003",
"autoDetected": false,
"startTime":"2014-05-19T23:26:54+07:00",
"duration": 0,
"sleepDetails":[
{
"datetime":"2014-05-19T23:26:54+07:00",
"value":2
},
{
"datetime":"2014-05-19T23:59:22+07:00",
"value":1
},
...
]
},
...
]
}
Please login to https://build.misfit.com with your developer account and find your app to set up the subscription endpoint and resources.
Please login to https://build.misfit.com with your developer account and find your app to set subscription resources. ‘Enabled’ to ‘Off’
After a third-party subscribes to notifications, Amazon SNS will POST a confirmation message to the third-party endpoint.
The third-party needs to parse the SNS message and look for the “SubscribeURL” value, and perform HTTP GET to that URL to confirm the subscription.
Only then can the endpoint receive notifications.
Subscription confirmation example
POST / HTTP/1.1
x-amz-sns-message-type: SubscriptionConfirmation
x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b
x-amz-sns-topic-arn: arn:aws:sns:us-east-1:123456789012:MyTopic
x-amz-sns-subscription-arn: arn:aws:sns:us-east-1:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55
Content-Length: 1336
Content-Type: text/plain; charset=UTF-8
Host: example.com
Connection: Keep-Alive
User-Agent: Amazon Simple Notification Service Agent
{
"Type" : "SubscriptionConfirmation",
"MessageId" : "165545c9-xxxx-472c-8df2-xxxxxxxxxxx",
"Token" : "xxxx",
"TopicArn" : "arn:aws:sns:us-east-1:123456789012:MyTopic",
"Message" : "You have chosen to subscribe to the topic...",
"SubscribeURL" : "https://xxxx.xxx",
"Timestamp" : "2012-04-26T20:45:04.751Z",
"SignatureVersion" : "1",
"Signature" : "EXAMPLEpH+xxxxx+xxxxx=",
"SigningCertURL" : "xxxxxx"
}
The third-Party endpoint will receive POST data directly from Amazon SNS.
The payload contains SNS wrapper data.
The third-Party needs to parse the “Message” field and then convert the payload to a JSON object to process the actual resource changes.
Resource change data is an array of changes having a “type” value indicating the resource type.
The “action” field indicates whether the resource was “created”, “updated” or “deleted”.
Notification format
A notification include several message objects.
Message object parameter:
parameter | type | optional | description |
---|---|---|---|
type | string | no | resource type |
action | string | no | change action |
id | string | no | resource Id |
ownerId | string | no | owner Id |
updateAt | string | no | updated time |
Example
{
"Type": "Notification",
"MessageId": "2860c564-624b-52ed-a445-8e2b6275b0fa",
"TopicArn": "arn:aws:sns:us-east-1:819895241319:resource-thirdparty1",
"Message": [
{
"type": "profiles",
"action": "created",
"id": "1234",
"ownerId": "51a4189acf12e53f79000001",
"updatedAt": "2014-01-01 12:00:00 UTC"
},
{
"type": "goals",
"action": "deleted",
"id": "abcdef12345",
"ownerId": "51a4189acf12e53f79000001",
"updatedAt": "2014-01-01 13:00:00 UTC"
},
{
"type": "goals",
"action": "updated",
"id": "abcdef123456",
"ownerId": "51a4189acf12e53f79000001",
"updatedAt": "2014-01-01 13:00:00 UTC"
},
...
],
"Timestamp": "2014-01-14T09:06:06.756Z",
"SignatureVersion": "1",
"Signature": "xxxxx/xxxxxx/xxxx==",
"SigningCertURL": "xxxxxxxx",
"UnsubscribeURL": "https://xxxx"
}