The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
Anyone know an API endpoint that'll give the last request timestamp for a given users? We've found last login but need the last request that shows up on the user profile screen.
Solved! Go to Solution.
If I understand you correctly. You want the last page view (any click) in Canvas from the API without having to do some looping?
Return a paginated list of the user's page view history in json format, similar to the available CSV download. Page views are returned in descending order, newest to oldest.
So, I think this is all you need.
/api/v1/users/self/page_views?per_page=1
The last record should be the last page view for any user.
fetch(`/api/v1/users/self/page_views?per_page=1`, {
'headers': {
'accept': 'application/json',
}
})
.then(r => r.json())
.then(r => console.log(r))Now I'm getting mixed results, because when I run the request, I see the request as the last page view. So, if test with per_page=2, the second to last one shows a refresh of a page I want to see.
// (2) [{…}, {…}]
// 0:
// url: "/api/v1/users/self/page_views&per_page=1"
// ...
// created_at: "2020-04-21T23:46:14Z"
// updated_at: "2020-04-21T23:46:14Z"
// ...
// 1:
// url: "/courses/1234567/pages/module-0-orientation-overview?module_item_id=11181794"
// ...
// created_at: "2020-04-21T23:45:38Z"
// updated_at: "2020-04-21T23:45:38Z"
// ...Sanity Check?
If I refresh x.instructure.com/accounts/self/users/self, showing me my own profile.
Then, run the API request for page_views, the last record from the API will be that.
Is that what you're looking for?
If I understand you correctly. You want the last page view (any click) in Canvas from the API without having to do some looping?
Return a paginated list of the user's page view history in json format, similar to the available CSV download. Page views are returned in descending order, newest to oldest.
So, I think this is all you need.
/api/v1/users/self/page_views?per_page=1
The last record should be the last page view for any user.
fetch(`/api/v1/users/self/page_views?per_page=1`, {
'headers': {
'accept': 'application/json',
}
})
.then(r => r.json())
.then(r => console.log(r))Now I'm getting mixed results, because when I run the request, I see the request as the last page view. So, if test with per_page=2, the second to last one shows a refresh of a page I want to see.
// (2) [{…}, {…}]
// 0:
// url: "/api/v1/users/self/page_views&per_page=1"
// ...
// created_at: "2020-04-21T23:46:14Z"
// updated_at: "2020-04-21T23:46:14Z"
// ...
// 1:
// url: "/courses/1234567/pages/module-0-orientation-overview?module_item_id=11181794"
// ...
// created_at: "2020-04-21T23:45:38Z"
// updated_at: "2020-04-21T23:45:38Z"
// ...Sanity Check?
If I refresh x.instructure.com/accounts/self/users/self, showing me my own profile.
Then, run the API request for page_views, the last record from the API will be that.
Is that what you're looking for?
Thanks Robert, this is what we ended up landing on. On the user profile page in the UI, there's a "Last Request" date. We were trying to pull that directly but we're using the page views api to get the data we want.
Community helpTo 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