Motivation RPG

Developer API


Authentication

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}

Error Handling

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.


GET /api/user/{username}

Returns information about a given user

Response

Field Description Auth Required
usernameThe username (which you provided)no
lastclickTimestamp of the user's last activityno
delaysecondsUser's chosen period between activitiesno
currenttimeThe server's current timestampno
nextclickThe calculated timestamp of the next activity. This can be in the past.no
raceCharacter typeno
fitnessintensityThe 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

Example

Request
curl -H "Authorization: Basic MjE3MTE1YjIzYjIyOGY1OGQyNWNhYjNhNjIwYWVkYzQ=" https://www.motivationrpg.com/api/user/motivateduser
Response

		{
		  "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"
		  }
		}
	
Possible Use Scenarios
Use 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.
FAQDevelopersPrivacyContact