Portal items- number of views

2379
11
05-02-2018 09:47 PM
JosephJose
New Contributor III

Somewhere in conversation, I came across a json url which gives me the number of views on the particular item be it a webmap, app, kml.

Have lost it .Can someone point me out correctly?

Is it something that only an admin can do?

11 Replies
XanderBakker
Esri Esteemed Contributor

Each item in portal has a property "numViews":

Item—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers 

See an example using Python to get the items sorted by the number of views (at the bottom of the page):

Example: Update the URL of a service in a web map—Portal for ArcGIS (10.6) | ArcGIS Enterprise  

I guess you will need to have access to the items to be able to retrieve the properties.

JosephJose
New Contributor III

That's near to what I wanted. We have few items not worth running a script.

Can you give me the Url that returns me the number of items in html , json formats? You know something like <portal>.arcgis.com\sharing\rest\....\....\ where I can view the output

0 Kudos
JosephJose
New Contributor III

why do certain people come and just post in answers not even fully understanding the question? Everyone here isn't looking for APIs though it's a good medium

JonathanQuinn
Esri Frequent Contributor

Anything you're looking at in the Portal home app is driven from an API...

Anyway, you can use the home app to find the number of views:

https://<portal>.<domain>.com/portal/home/item.html?id=<itemID>

Or users content within Sharing API that the home app is getting its information from:

https://<portal>.<domain>.com/portal/sharing/rest/content/users/<user>/items/<itemID>

Or by searching in the home app:

Or by searching in the Sharing API, which is what searching in the Sharing API is giving you:

BorjaParés_Fuente
New Contributor II

Hi all,

is it possible to retrieve the numviews property filtered by user? I mean, is there any log where I could find the items viewed by a user?

Thanks in advance.

AdrienComp
New Contributor

Hello @BorjaParés_Fuente , 

I came across your comment and this is exactly one of the things I am currently trying to achieve! This was three years ago, but maybe you remember how you solved this? Thanks for any tip you might have. 

0 Kudos
ClayGrant
New Contributor

Xander,

   Is it possible to reset the numViews value back to zero? 

0 Kudos
TimothyMichael
Occasional Contributor II

Using the ArcGIS API for Python you can do the following:

import arcgis
from arcgis.gis import GIS

# Org URL
url = "https://nation.maps.arcgis.com"

# Make a connection to the portal
gis = GIS(url=url)

# Item ID
# Using a public story map for this example
# https://nation.maps.arcgis.com/apps/Cascade/index.html?appid=e4ae5b57cf9045288909a93cc31cde7c
item = "e4ae5b57cf9045288909a93cc31cde7c"

i = gis.content.get(item)
print(i['numViews'])‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
hoogw
by
New Contributor III

I found a bug/error in ESRI REST API, please fix the bug in code or update doc either way:

https://developers.arcgis.com/rest/users-groups-and-items/item.htm

the api reads:      

https://<content-url>/items/<itemId>

also give example at bottom

https://www.arcgis.com/sharing/rest/content/items/10ba62fe50864339a8a3e0f18ca85506

You actually will NOT get any info by use above link format. Only a blank page

You must add  

?f=json

by define format to get something

This is a working example:

https://www.arcgis.com/sharing/rest/content/items/a22e7905d67f4330bbec630eebd38419?f=json 

esri staff, please fix the rest api code, by define 'f=json' format by default.

or update the rest api doc above, by put a NOTE: * remind user must append ?f=json at the url end

0 Kudos