Your Community is getting an upgrade!
Read about our partnership with Higher Logic and how we will build the next generation of the Instructure Community.
Hi Lee,
There's not really a "logged in since..." API, but certain calls within the Users API can get you the last time the person logged in. For instance, if you grab all the users in the account and sort by last login:
https://<server>/api/v1/accounts/1/users?sort=last_login
you get back the last login date as part of the user record for all the users in the account. I'm not sure what it does with users who have never legged in, though.
You can also get at this information for a specific user (kind of) by looking for the last page view for that user:
https://<server>/api/v1/users/<user id>/page_views?per_page=1
And of course, you can also run the "last access" report under Settings > Reports.
Other folks may have better ways to gather this info, though!
Mike
the enrollments API also includes a "last_activity_at" field which can be queried on a course-by-course basis. Here's an example of adding an indicator to the people page for those that have been active recently:
The endpoint that Mike provided is good. I just used it this morning to write code that would track logins in mostly real-time (I don't have Live Events enabled, which would probably be easier). It probably would have been easier if I would have found Mike's post first, I stumbled upon it and just wondered what sorting by last_login would do and it added the last_login.
This will show the most recent logins across the institution:
GET /api/v1/accounts/self/users?sort=last_login&order=desc
What I did was extract the most recent date from my database and then fetch the information not following pagination to its completion, but only until I passed that previous date. I then run the code periodically throughout the day to update the last logins.
As I was reading through the source code changes mentioned in the 2020-07-29 deploy notes, I thought I found something new, but it turns out that some people knew about it back in 2018; perhaps it was undocumented.
For individual users, you can use
GET /api/v1/users/:user_id?include[]=last_login
:user_id can be the numeric Canvas user ID or you can use sis_user_id:5678 format.
To interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign InTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign In
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.