function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

API access to login history

is it possible to access login history details of a user through API ? please do mention the api version too


No, login history is not currently exposed via the API.


it’s not possible but you can download  from your org using salesforce user interface.


You should be able to access it now via Login History (LoginHistory)


Latest release of salesforce has an object name LoginHistory using which you can access the login history of any user.

For a particular user, you need to mention userID in SOQL query:

public void someFunction(){
    LoginHistory logH= [select field1,field2,... from LoginHistory where userID='some_User's_id' limit 1];
    // for one record.
    // for multiple records you can store results in a list.
In case you want to get login details of current user then use following line instead.
LoginHistory logH=[select field1,field2,... from LoginHistory where userID=:userInfo.getUserID()];

for detailed documentation, navigate to following page: