4

I want to show a list on our homepage of the most popular pages in our site collection. Is there a way of accessing this information using REST?

1 Answer 1

3

Use the ViewsLifetime and ViewsRecent metadata returned from http://site/subsite/_api/search/query (such as http://site/subsite/_api/search/query?querytext='ContentTypeId:0x010100C568*'). No views is a null value.

(in JSON the return looks like)

20:  {
__metadata: {
type: "SP.KeyValue"
}-
Key: "ViewsLifeTime"
Value: "246"
ValueType: "Edm.Int64"
}-
21:  {
__metadata: {
type: "SP.KeyValue"
}-
Key: "ViewsRecent"
Value: "98"
ValueType: "Edm.Int64"
}
2
  • Where did you get ContentTypeId:0x010100C568* from?
    – matt
    Commented Apr 8, 2015 at 20:48
  • That's just the default starting prefix for a page content type. Its just as an example of the search functionality. You can get a the content type ID's from Powershell, SP Designer or by going to Site Settings > Content Types and looking at the shortcuts. You could search by most any tag available in the metadata (name, title, author, etc). Microsoft has their API syntax reference <a href="msdn.microsoft.com/en-us/library/office/…>
    – Graham
    Commented Apr 8, 2015 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.