Package: litmos-api
Litmos REST API client for python 3.6 and aboveFree software: BSD licenseInstallationpip install litmos-apiGetting startedfromlitmosimportLitmosAPI_KEY='AXXXXXXXXXX'LITMOS_APP_NAME='jins.litmos.com'LITMOS_SERVER_URL='https://api.litmos.com/v1.svc'# https://support.litmos.com/hc/en-us/articles/227734667-Overview-Developer-APIlitmos=Litmos(API_KEY,LITMOS_APP_NAME,LITMOS_SERVER_URL)# --- User ---# retrieve usersall_users=litmos.User.all()# retrieve all users (with all information populated - default /users/all API endpoint only returns a subset of user fields)# much longer than .all() as individual requests to /find/{user-id} for every user are madeall_users_with_full_details=litmos.User.all(True)#find user by Iduser=litmos.User.find('rnjx2WaQOa11')# search for user by usernameuser=litmos.User.search('beelzebub@pieshop.net')# update JobTitle & City fieldsuser.JobTitle='Pie eater'user.City='Pieland'# save useruser.save()# deactivate useruser.deactivate()# create useruser=litmos.User.create({'UserName':'jobaba72@pieshop.net','FirstName':'Jo','LastName':'Baba72','Email':'jobaba72@pieshop.net'})# get teams for a useruser.teams()# remove all teams from useruser.remove_teams()# delete user# with Idlitmos.User.delete('YmrD112qlm41')# instance deleteuser.destroy()# set a user's manageruser.set_manager('jdhaskdhlsa')# or pass in a user objectmanager=litmos.User.find('rnjx2WaQOa11')[0]user.set_manager(manager)# advanced custom fields# https://support.litmos.com/hc/en-us/articles/227735427-User-Custom-Fieldsuser.update_advanced_custom_fields([{"fieldnamex":"value1"},{"fieldnamey":"value2"}])# --- Team ---# get all teamsall_teams=litmos.Team.all()# find team by Idteam=litmos.Team.find('rnjx2WaQOa11')# get team membersusers=team.users()# get team leadersleaders=team.leaders()# get team adminsadmins=team.admins()# create team (at root level)team=litmos.Team.create({'Name':'A-Team','Description':'I pity the fool!'})# add sub-teamsub_team=litmos.Team()sub_team.Name='B-Team'sub_team.Description='Woohoo'sub_team_id=team.add_sub_team(sub_team)# assign courses to teamcourse1=litmos.Course.find('d2cJSDvIU0c1')course2=litmos.Course.find('d2cJSDvIU0c2')team.assign_courses([course1,course2])# unassign courses to teamcourse1=litmos.Course.find('d2cJSDvIU0c1')course2=litmos.Course.find('d2cJSDvIU0c2')team.unassign_courses([course1,course2])# --- Team members ---# add users to teamuser1=litmos.User.find('rnjx2WaQOa11')user2=litmos.User.find('rnjx2WaQOa12')team.add_users([user1,user2])# remove users from teamteam.remove_user(user2)# --- Team leaders ---# promote userteam.promote_team_leader(user1)# demote userteam.demote_team_leader(user1)# --- Team admins ---# promote userteam.promote_team_admin(user1)# demote userteam.demote_team_admin(user1)Documentationhttps://python-litmos-api.readthedocs.io/DevelopmentTo run the all tests run:pip install -r requirements.txt
cd tests
nosetestsChangelog1.0.0 (2020-07-30)Add ability to update a user’s manager via the manager ID or passing in a user objectAdd ability to handle advanced custom fields on User objecthttps://support.litmos.com/hc/en-us/articles/227735427-User-Custom-Fields0.1.1 (2019-08-19)Add assign and unassign courses methods to Team class.0.1.0 (2016-12-07)First release on PyPI.