<?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: API to Get Item Usage in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865804#M4420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cameron,&lt;/P&gt;&lt;P&gt;I was led here by your&amp;nbsp; post in GitHub, and I also commented there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Esri/arcgis-python-api/issues/321" title="https://github.com/Esri/arcgis-python-api/issues/321"&gt;item.usage() errors · Issue #321 · Esri/arcgis-python-api · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Dec 2018 08:17:18 GMT</pubDate>
    <dc:creator>simoxu</dc:creator>
    <dc:date>2018-12-03T08:17:18Z</dc:date>
    <item>
      <title>API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865800#M4416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning,&lt;/P&gt;&lt;P&gt;I have been pulling some item usage data from AGOL using the Python API item.usage().&lt;/P&gt;&lt;P&gt;Seems to be working fine for a few of the queries, and not for others.&lt;/P&gt;&lt;P&gt;My python:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;Item
gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;organiztion&amp;gt;.maps.arcgis.com"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;username&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;password&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Item&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;itemid&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
chartdata &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;usage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;daterange&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;as_df&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;chartdata&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The chart below shows which ones work for me.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="errors" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/427785_PythonAPIErrors.png" /&gt;&lt;/P&gt;&lt;P&gt;If I run the 6M range, it returns:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Error generating usage report&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
None
Error generating usage report&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I run the 1Y range, it returns:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Traceback &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;most recent call last&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"&amp;lt;filepath&amp;gt;.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;12&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;module&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
 chartdata &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;usage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"1Y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;as_df&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"&amp;lt;windowsuserfolder&amp;gt;\AppData\Local\ESRI\conda\envs\new-environment\lib\site-packages\arcgis\gis\__init__.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;6371&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; usage
 &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; ValueError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Invalid date range."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
ValueError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Invalid date range&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It doesn't matter whether you return the Pandas DataFrame or the python dictionary for the result, same errors get generated.&lt;/P&gt;&lt;P&gt;Am I missing something somewhere?&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be really nice to get the&amp;nbsp;longer date ranges for my automated reporting I'm working on.&lt;BR /&gt;Thanks for any help on this!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Cameron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:45:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865800#M4416</guid>
      <dc:creator>CameronMcCormick</dc:creator>
      <dc:date>2021-12-12T10:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865801#M4417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you able to run the queries for 6 and 12 months in AGOL's web page interface?&amp;nbsp; It could be an AGOL issue and what you are seeing is a symptom of that non-Python issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 14:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865801#M4417</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-11-05T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865802#M4418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes both the 6 months and 1 year queries work in AGOL&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/427792_Capture6M.PNG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 15:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865802#M4418</guid>
      <dc:creator>CameronMcCormick</dc:creator>
      <dc:date>2018-11-05T15:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865803#M4419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems the maximum days in one request is restricted to 60 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I searched 1 year in AGOL, and the startTime and endTime in the requests sent by the browser to AGOL are:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1512283405000&lt;BR /&gt;endTime: 1517467405000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1517467405000&lt;BR /&gt;endTime: 1522655005000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1522655005000&lt;BR /&gt;endTime: 1527839005000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1527839005000&lt;BR /&gt;endTime: 1533023005000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1533023005000&lt;BR /&gt;endTime: 1538207005000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1538207005000&lt;BR /&gt;endTime: 1543387405000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;startTime: 1543387405000&lt;BR /&gt;endTime: 1543819405000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Convert these timestamp (in milliseconds) to datetime, you'll find the regularity:&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;DIV class="" style="color: #000000; background: transparent; border: none; padding: var(--jp-cell-padding);"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class="" data-type="inline" style="background: var(--jp-cell-editor-background); border: var(--jp-border-width) solid var(--jp-cell-editor-border-color);"&gt;&lt;DIV class="" style="color: var(--jp-content-font-color1); background: transparent; font-size: var(--jp-code-font-size);"&gt;&lt;DIV&gt;time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1512283405))&lt;/DIV&gt;&lt;DIV class="" style="margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px;"&gt;&lt;DIV class="" style="border-right: 13px solid transparent; margin-bottom: -17px;"&gt;&lt;DIV&gt;&lt;DIV class="" style="padding: var(--jp-code-padding);"&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;PRE style="color: var(--jp-content-font-color1); background-color: #ffffff; border: none; font-size: 13px;"&gt;'2017-12-03 17:13:25'&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;This is a bug for the API if the document clearly states it can take 6m and 1y as the date range.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;A href="https://community.esri.com/migrated-users/305084"&gt;David Vitale&lt;/A&gt;‌&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2018 06:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865803#M4419</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2018-12-03T06:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865804#M4420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cameron,&lt;/P&gt;&lt;P&gt;I was led here by your&amp;nbsp; post in GitHub, and I also commented there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Esri/arcgis-python-api/issues/321" title="https://github.com/Esri/arcgis-python-api/issues/321"&gt;item.usage() errors · Issue #321 · Esri/arcgis-python-api · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Dec 2018 08:17:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865804#M4420</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2018-12-03T08:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: API to Get Item Usage</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865805#M4421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This specific issue has been address in the new release of 1.5.2.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Esri/arcgis-python-api/blob/master/guide/02-api-overview/release-notes.ipynb" title="https://github.com/Esri/arcgis-python-api/blob/master/guide/02-api-overview/release-notes.ipynb"&gt;arcgis-python-api/release-notes.ipynb at master · Esri/arcgis-python-api · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Dec 2018 23:27:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-to-get-item-usage/m-p/865805#M4421</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2018-12-06T23:27:43Z</dc:date>
    </item>
  </channel>
</rss>

