title: How to get the File Type of a File in Sharepoint
body: <p>I'm trying to load in documents from the Documents library in SharePoint and I want to be able to filter them by file type (Word Doc, Excel Sheet, etc.) from my application. I've figured out how to get the icon for the file type using <code>mapToIcon</code>, but I can't seem to find anywhere how to get the file type. </p>
  
  <p>Is there any function or API call to get the file type of a file? I would prefer to not have to hard code each type based on file extension but I may need to do that.</p>
  
  <p>Here is a bit of my code for reference</p>
  
  <pre><code>// data returned from an ajax call to get all documents
  var results = data.d.results;
  
  for(var i = 0; i &lt; results.length; i++){
      // get the name of the document
      var name = results[i].Name;
  
      // retrieve the icon for the file type through an ajax call
      var icon;
      $.ajax({
              url: siteUrl + "/_api/web/maptoicon(filename='" + name + "',progid='',size=0)"
              /*headers*/,
              success: function(data){
                  // get the icon
                  icon = data.d.MapToIcon;
              },  
          });
      }
  </code></pre>