TRZ API 3.1


Classes

7 Things To Remember




HTTP Status Response

Evaluate the actual HTTP status instead of JSON status codes.

200 : success.
401 : unauthorized (auth creds not correct, cannot login)
403 : Exceeded max access count for api.
403 : forbidden (client can only modify own records, trainer can modifies group's records)
404 : user or entity ID not found
406 : unable to parse params, or params don't make sense or give errors
500 : error occured(any error or crashes)



Success Codes

0 : Indicates success


Error Codes

The API may send the following error codes. Other codes may be added in the future.

rate_limit_exceeded : The rate limit for the App has been exceeded
api_plan_restricted : The API is not available on this App’s Plan
client_only : this feature is for a client only
trainer_only : this feature is for a trainer only
type_mismatch : The JSON value type is incorrect for the field
parameter_not_found : A required parameter was not supplied
parameter_invalid : A parameter’s value is invalid


Tech Notes

To get the current Authenticated user.
Use SignedIn

To get the group of Authenticated user.
Use CurrentGroup

Authentication headers scheme


Titanium permanent token:
v6 Browser temporary token:

Authentication is through the header
Sample: Authorization : TRAUV1 3_OAFMBQLSUWYGUWYADEXD
TRAUV1 is a hard coded string to identify the type of the token
3_OAFMBQLSUWYGUWYADEXD will combine the userid and login token


Permanent partner API token:
Trainerize use the Basic Authentication for permanent partner API.
The Authentication token will base64 encoding of groupID:APIToken.
Sample: Authorization: Basic [Base64Encoded(groupID:APIToken)] Please get the token from Trainerize Dev Team


Access control

API will have limit number of access. It controlled by pre-IP/pre-day.
See the current limit: SYS/GetAccessLimit
Changet the current limits: SYS/SetAccessLimit
Get the current stats: SYS/GetAccessStats
Clear stats: SYS/ClearAccessStats


Referrer API to web app/ mobile app

referral (www.trainerize.com/referral.aspx)mobilemobile behaviourwebweb behaviour
action=msg.new&recipients=1,2,3trainerize://?action=msg.new&recipients=1,2,3opens msg dialog and adds userID as recipients/app/messages/?view=inbox#mode=newMsg&recipients=1,2,3open new mesage dialog
action=clients.viewNotSetupAfter3Daystrainerize://?action=clients.viewNotSetupAfter3Daysopens client grid/app/group/client.aspx#mode=clients.viewNotSetupAfter3Daysopens client grid - goes to tag not setup after 3 days
action=clients.viewNeedNewTrainingPlantrainerize://?action=clients.viewNeedNewTrainingPlanopens client grid/app/group/client.aspx#mode=clients.viewNeedNewTrainingPlanopens client grid - goes to tag needs new training plan
action=clients.viewNotSignedInLatelytrainerize://?action=clients.viewNotSignedInLatelyopens client grid/app/group/client.aspx#mode=clients.viewNotSignedInLatelyopens client grid - goes to tag not signed in lately
action=clients.viewLastMessagedtrainerize://?action=clients.viewLastMessagedopens client grid/app/group/client.aspx#mode=clients.viewLastMessagedopens client grid - goes to all activated (last message)
action=clients.viewActivetrainerize://?action=clients.viewActiveopens client grid/app/group/client.aspx#mode=clients.viewActiveopens client grid - goes to all activated
action=msg.opentrainerize://?action=msg.open&threadID=123opens up msg dialog for the threadnot implemented 
action=group.opentrainerize://?action=group.open&groupID=123opens up group dialog from groupIDnot implemented 
action=dailyWorkout.opentrainerize://?action=dailyWorkout.open&dailyWorkoutID=123(For client)opens up workout dialognot implemented 
not implementedtrainerize://?action=trainerUpdate.calendaropens up calendar and updates not implemented 
not implementedtrainerize://?action=trainerUpdate.trainingPlanopens up training plan and updates not implemented