Most API calls can be made with or without authorization. A non-authorized call will return a basic set of information, but an authorized query will return extra information. A request made with an invalid authorization header will fail.
Each user has its own API key which you can find freely on the options page. This is to be provided to the API endpoints using the Authorization
header, with the content Basic APIKEY
where APIKEY is the one provided in the user's options page.
curl -H "Authorization: Basic {Api_Key}" https://www.motivationrpg.com/api/user/{username}
Trying to access a resource that does not exist (for example, a nonexistent username) returns status 404 Not Found and the JSON content
["Error", "Username not found"]
Attempting to authorize with an invalid API key returns a status 401 Unauthorized and no JSON content.
Returns information about a given user
Field | Description | Auth Required |
---|---|---|
username | The username (which you provided) | no |
lastclick | Timestamp of the user's last activity | no |
delayseconds | User's chosen period between activities | no |
currenttime | The server's current timestamp | no |
nextclick | The calculated timestamp of the next activity. This can be in the past. | no |
race | Character type | no |
fitnessintensity | The username (which you provided) | yes |
nextactivity ├ title ├ description └ section | Information about the next activity ├ Name of the activity ├ Longer description of the instructions └ The RPG statistic that will be affected If the user has no activities in their list (this should not be possible), nextactivity just returns the string 'none'. | yes |
rpgstats ├ xp ├ coins ├ fitness ├ voice ├ mood ├ health ├ intelligence └ posture | RPG Character stats └ Self descriptive | yes |
curl -H "Authorization: Basic MjE3MTE1YjIzYjIyOGY1OGQyNWNhYjNhNjIwYWVkYzQ=" https://www.motivationrpg.com/api/user/motivateduser
{
"username": "MotivatedUser",
"lastclick": 1602309081,
"delayseconds": 1200,
"currenttime": 1602380653,
"nextclick": 1602310281,
"race": "Ent",
"fitnessintensity": 9,
"nextactivity": {
"title": "Arm stretch",
"description": "Arm stretch. Stretch with your fingertips to the opposite walls. Breathe and relax.",
"section": "fitness"
},
"rpgstats": {
"xp": "384",
"coins": "301",
"fitness": "123",
"voice": "15",
"mood": "10",
"health": "37",
"intelligence": "10",
"posture": "42"
}
}
currenttime
and nextclick
to determine exactly how long until the user's next activity, show them a timer that links back to https://www.motivationrpg.com/play.php when it runs out.