Getting Current Logged In User Using Rest API In SharePoint Online And Get User Details Using User ID

There are two important REST API Services available to get the current logged in user or get full account details using the userId.
  1. https://<<site details>>/sites/_api/web/currentuser    
This will return complete details of the current logged user in your data in XML. If it is run in the browser itself, we can create an AJAX call and get particular value (or) filter it.
  1. https://<<site details>>/sites/_api/web/currentuser/_api/web/currentuser?$select=Title,Email,Id   
Another way of getting value using User Id value is to consume "_layouts/15/userdisp.aspx" and pass userId as query string value and get complete myblog site as response.
  1. https://<<site details>>/sites/_api/web/currentuser/_layouts/15/userdisp.aspx??ID=<User ID value>   
Complete function 
  1. function GetUserDetails() {  
  2.     var url = "" + "/_api/web/currentuser";  
  3.     $.ajax({  
  4.         url: url,  
  5.         headers: {  
  6.             Accept: "application/json;odata=verbose"  
  7.         },  
  8.         async: false,  
  9.         success: function (data) {  
  10.             var items = data.d.results; // Data will have user object      
  11.         },  
  12.         eror: function (data) {  
  13.             alert("An error occurred. Please try again.");  
  14.         }  
  15.     });  
  16. }  
Debugger Console screenshot.

The Data object contains all user profile properties.