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
prasunprasun 

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

SuperfellSuperfell

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

Pradeep_NavatarPradeep_Navatar

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

eval10eval10

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

mrizmriz

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:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_loginhistory.htm