Is it possible to get a list of all arcgis online items with the python module?
This is the API reference https://esri.github.io/arcgis-python-api/apidoc/html/
What specifically is it you need?
Couldn't find anything in the reference. I'm looking for a way to get a list of all items in my AGO account.
You could try searching using an owner filter like:
gis.content.search("owner:my_username", max_items=1000)
If you authenticate with your account, then it should find everything you own.
arcgis.gis module — arcgis 1.4.0 documentation
The API reference above is correct. There is a search method which should do exactly what you need.
Maybe this script can help.
The output will export excel files contains all parameters like title, type, itemid, etc.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS <SPAN class="keyword token">import</SPAN> pandas <SPAN class="keyword token">as</SPAN> pd portal <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"url portal"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"username"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"password"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#set "max_users" parameters in search() if you have more than 100 users in your portal</SPAN> users_all <SPAN class="operator token">=</SPAN> portal<SPAN class="punctuation token">.</SPAN>users<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">def</SPAN> <SPAN class="token function">get_item</SPAN><SPAN class="punctuation token">(</SPAN>user<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> list_items <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="punctuation token">}</SPAN> content_item <SPAN class="operator token">=</SPAN> user<SPAN class="punctuation token">.</SPAN>items<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> content_item<SPAN class="punctuation token">:</SPAN> list_items<SPAN class="punctuation token">[</SPAN>item<SPAN class="punctuation token">.</SPAN>itemid<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> item folders <SPAN class="operator token">=</SPAN> user<SPAN class="punctuation token">.</SPAN>folders <SPAN class="keyword token">for</SPAN> folder <SPAN class="keyword token">in</SPAN> folders <SPAN class="punctuation token">:</SPAN> folder_items <SPAN class="operator token">=</SPAN> user<SPAN class="punctuation token">.</SPAN>items<SPAN class="punctuation token">(</SPAN>folder<SPAN class="operator token">=</SPAN>folder<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'title'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> folder_items<SPAN class="punctuation token">:</SPAN> list_items<SPAN class="punctuation token">[</SPAN>item<SPAN class="punctuation token">.</SPAN>itemid<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> item pd<SPAN class="punctuation token">.</SPAN>DataFrame<SPAN class="punctuation token">(</SPAN>list_items<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>transpose<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>to_excel<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>user<SPAN class="punctuation token">.</SPAN>username<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">'.xlsx'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>users_all<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"extract "</SPAN><SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>users_all<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"data to excel..."</SPAN><SPAN class="punctuation token">)</SPAN> get_item<SPAN class="punctuation token">(</SPAN>users_all<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
If I don't have an enterprise portal where does the Excel end up? It doesn't show up in my organization's content in AGO. The script seems to run fine and loops through my users, but I can't figure out where the exports are located.
Is there something I can add to the script to download the Excel after its been exported?
I know this is a bit old but you can just modify the script to specify an output location:
pd.DataFrame(list_items).transpose().to_excel('C:\\temp\\' + str(user.username)+'.xlsx')
@ConorMacNaughton wrote:If I don't have an enterprise portal where does the Excel end up? It doesn't show up in my organization's content in AGO. The script seems to run fine and loops through my users, but I can't figure out where the exports are located.Is there something I can add to the script to download the Excel after its been exported?
Great script thanks.
The script is great! Thanks for sharing... I have been trying to perform this task but in my case, I just need to list the items inside a specific folder within AGOL's content folders. I like the way the original scripts outputs the table with title, type, itemid. Any assistance will be appreciated!
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.