How can we help you today?

How to Display Most Popular Items with ShortPoint REST API

ShortPoint lets you display any type of documents from your SharePoint libraries. The most commonly requested connection that a user wants to achieve is to display recently and the most visited documents across your SharePoint pages. In this article, we will show you how to achieve this connection by using the REST API magic. 

Note: ShortPoint Page Builder Live Mode was formerly known as Visual Builder and Grid Mode was formerly known as Wireframe Builder. Also, ShortPoint Page Builder version 7 and below are now referred to as Legacy Page Builder. 

TABLE OF CONTENTS


Prerequisite

  • You have files added in your SharePoint document library/libraries.
  • You already have a ShortPoint Design Element added to the page.
  • Make sure is ShortPoint installed on your SharePoint sites(s). We recommend you to always have the latest version installed. Visit our Download ShortPoint page and get the latest version of ShortPoint.
  • Make sure you are a ShortPoint user with an active license.

Step 1: Edit existing ShortPoint Design Element

In edit mode, open the settings of your Design Element.


Info: Currently, configuring ShortPoint connections is only supported in the ShortPoint Page Builder Grid Mode. Make sure to switch to it, if you are in Live Mode:

Switch to the Wireframe Builder


Click the cog wheel icon as shown below: 

  • New ShortPoint Page Builder Grid Mode:


Click the cog wheel


  • Legacy Page Builder:

Click the cog wheel


The Settings tab will open:


Open the settings tab


Step 2: Configure the REST API settings


In edit mode of your ShortPoint Design Element, you will be able to establish a connection from the SharePoint document library that you want to connect to. Please follow these steps below on how to proceed with the configuration.


2.1 Set up the REST API connection URL


Switch to the Connect tab and choose REST API from the connection options:


Go to Rest API Connection


Note: To have an overview of ShortPoint connect features, you may visit ShortPoint Connect: Basic Tutorial.


In the REST API URL, paste the following URL (items highlighted with red requires editing) depending on the results that you want to get.

If you want to display recently visited documents in the entire tenant, use this REST API URL:


https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt"
,"pptx","mpp","csv","txt")
'&sortlist='ViewsRecent:descending'



Or, if you want to display most visited documents in the entire tenant, use this REST API URL:


https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt"
,"pptx","mpp","csv","txt")
'&sortlist='ViewsLifeTime:descending'


siteURL- should be replaced with the site URL (root site, site collection, subsite) where the SharePoint list is located;


For example, our REST API URL looks like this:

https://somewhatcompany.sharepoint.com /_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls","xlsx","ppt",
"pptx","mpp","csv","txt")'&sortlist='ViewsRecent:descending'


Where:

  • somewhatcompany.sharepoint.com is your SharePoint tenant;
  • '&sortlist='ViewsRecent:descending' is your query to display recently visited documents.
  • '&sortlist='ViewsLifeTime:descending' is your query to display most visited documents.



Note: If you want to refine the results to a specific site or multiple site, you have to add extra filters in the queryText:



By SiteId: AND (SiteId: 00000-0000-000-0000) OR SiteId: {00000-0000-000-0000-0001}

By Site path: AND Path: https://{your-site-path}


For example:
https://siteURL/_api/search/query?querytext='ContentTypeId:"0x0101*" AND IsDocument:True AND (SiteId:{0000-000-0000-0000} OR SiteId:0000-00-000-000)'&rowlimit=1000&refinementfilters='fileExtension:or("docx","wmv","pdf","doc","xls" ,
"xlsx","ppt","pptx","mpp","csv","txt")'&sortlist='ViewsRecent:descending'


Step 3: Map the Items


Switch to the Items tab:


Go to the Items tab


Press the chain icon on the right of the Design Element field (for example, Title) and select which column of your SharePoint list/library correspond to it:


Map the items


Note: To know more about items mapping, please check our ShortPoint Connect: Basic Tutorial.


You may click the Preview button to check the results:


Preview the result

 

Then click Update to save your changes:


Insert Design Element


Result

That's it! You will now be able to display most popular documents across your SharePoint pages. Here is how it may look like on your page:

sample result


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 22 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more