<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get item usage with custom range that goes over a year in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1237009#M8083</link>
    <description>&lt;P&gt;Bumping this thread - Has anyone come up with a way to do this yet? I can't seem to find anything that works.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 21:02:28 GMT</pubDate>
    <dc:creator>sblack_USGS</dc:creator>
    <dc:date>2022-12-01T21:02:28Z</dc:date>
    <item>
      <title>Get item usage with custom range that goes over a year</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1051169#M5968</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used to check our web apps' usage since the app was created in the mid april in 2020 . Last week, I realized that the usage search only offers up to 1 year range, and had to some manual calculation to get the cumulated total and average usage per day. It was quite inconvenient and I hope to get the number using Python API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I searched some resources but I don't see any example which actually used a custom range. Has anyone done it? What all I need is total cumulated number and daily average.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if I cannot do over 1 year, if I can apply custom date range with Python API, I can probably skip manual calculation work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kerry&lt;/P&gt;</description>
      <pubDate>Mon, 26 Apr 2021 03:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1051169#M5968</guid>
      <dc:creator>KerryKang</dc:creator>
      <dc:date>2021-04-26T03:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get item usage with custom range that goes over a year</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1058822#M6071</link>
      <description>&lt;P&gt;I've been doing some hocky stuff off Jason's code. I was kinda hoping I could import pandas and use that as a date, something like:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;pd&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;date_range&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;start&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'2020-01-01'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;end&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'2020-01-06'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;but I can't get it to work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FYI:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from arcgis.gis import GIS
from IPython.display import display
gis = GIS("home")
items = gis.content.search(query="type:Web Apps")
for item in items:
   try:
      itemHistory = item.usage(date_range='1Y', as_df=True)   # &amp;lt;--- Looking in the past 12 months
      total = itemHistory['Usage'].sum()
      if total &amp;lt;20:                                                                           # &amp;lt;--- Less than 20 total views
         display(item)
   except:
      pass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 04:04:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1058822#M6071</guid>
      <dc:creator>AdamR</dc:creator>
      <dc:date>2021-05-18T04:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get item usage with custom range that goes over a year</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1237009#M8083</link>
      <description>&lt;P&gt;Bumping this thread - Has anyone come up with a way to do this yet? I can't seem to find anything that works.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 21:02:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1237009#M8083</guid>
      <dc:creator>sblack_USGS</dc:creator>
      <dc:date>2022-12-01T21:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get item usage with custom range that goes over a year</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1310604#M8893</link>
      <description>&lt;P&gt;Bumping this thread again.&amp;nbsp; I've gotten custom date ranges to work with this method:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gis = GIS('home')
item = arcgis.gis.Item(gis, itemid="########################")
date_1 = datetime.datetime(2023,7,2)
date_2 = datetime.datetime(2023,7,20)
usage_stats = item.usage(date_range=(date_1, date_2),as_df=True)
usage_stats&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;BUT, any custom dates over a year old fail.&amp;nbsp; &lt;/STRONG&gt;Well, technically I don't get an error.&amp;nbsp; I just get an empty dataframe.&amp;nbsp; Or an empty dictionary if I use "as_df = False".&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is this the expected behavior, or a bug?&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 17:44:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-item-usage-with-custom-range-that-goes-over-a/m-p/1310604#M8893</guid>
      <dc:creator>JoshuaFlickinger</dc:creator>
      <dc:date>2023-07-21T17:44:30Z</dc:date>
    </item>
  </channel>
</rss>

