<?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: Categorize items with the API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861725#M4219</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Morten,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you should be able to do it with the standard &lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html"&gt;Enterprise API &lt;/A&gt;with the assign_to_items() command.&lt;/P&gt;&lt;P&gt;That being said, I tried it with different json formats (categories and groupCategories - the second being how it actually is in the json for an item categorized into a group category vs what the example says) and it did not work (always returned "false" response).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you had any luck using the REST API? I have also been trying to categorize items into group categories in python.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Nov 2019 21:25:34 GMT</pubDate>
    <dc:creator>AdrienLepoutre</dc:creator>
    <dc:date>2019-11-01T21:25:34Z</dc:date>
    <item>
      <title>Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861718#M4212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to categorize items through the API (to group categories)? I would like to set this as a property just like title, tags etc. Is this not yet implemented in the API for Python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2018 11:23:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861718#M4212</guid>
      <dc:creator>MortenBjerrum1</dc:creator>
      <dc:date>2018-08-24T11:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861719#M4213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tested the following code in Python API 1.5.0, it works.&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
gis&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;url&lt;SPAN class="operator 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%2Forgname.maps.arcgis.com" target="_blank"&gt;https://orgname.maps.arcgis.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;username&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"abc"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# get the CategoryManager for this GIS&lt;/SPAN&gt;
cs&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;admin&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;category_schema

&lt;SPAN class="comment token"&gt;# get the item you want to work on&lt;/SPAN&gt;
item1&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;item ID&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# assign the item to the desired categories&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# you may need to create the categories first in AGOL &lt;/SPAN&gt;
cs&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;categorize_item&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'/Categories/People'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'/Categories/Boundaries'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&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;/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;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:41:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861719#M4213</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2021-12-12T10:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861720#M4214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the answer. It looks like the Category_schema is the schema for the entire GIS organisation. In this case I am using Group categories. How&amp;nbsp;to access them?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2018 08:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861720#M4214</guid>
      <dc:creator>MortenBjerrum1</dc:creator>
      <dc:date>2018-08-28T08:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861721#M4215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure I understand the question. what do you mean "Group categories"? is it "Sub Categories"? If yes, I guess you can access sub categories the same way using the code provided. CategoryManager is where all the relevant functions are implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.admin.html?highlight=categorymanager#categorymanager" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.admin.html?highlight=categorymanager#categorymanager"&gt;CategoryManager — arcgis 1.5.0 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Aug 2018 00:11:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861721#M4215</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2018-08-31T00:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861722#M4216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry if my question is unclear. There seems to be categories both at the organisation level and at group level - &lt;A href="https://doc.arcgis.com/en/arcgis-online/share-maps/own-groups.htm"&gt;https://doc.arcgis.com/en/arcgis-online/share-maps/own-groups.htm&lt;/A&gt;. Your script access the category_schema at the organisation level (from the gis object) but can I access a similar schema from the group level? Right now, I manually categorized all items but would still like to be able to do it with the API...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Sep 2018 09:42:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861722#M4216</guid>
      <dc:creator>MortenBjerrum1</dc:creator>
      <dc:date>2018-09-03T09:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861723#M4217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;uhm...&lt;/P&gt;&lt;P&gt;Unfortunately I can't find any implementation of the group category in Python API. So it seems you have to use REST API to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To list the the group content categories :&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm"&gt;Group Category Schema—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To&amp;nbsp;update the group content categories :&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/update-group-items-with-content-categories.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/update-group-items-with-content-categories.htm"&gt;Update Group Items with Content Categories—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Google "how to send http request using python" will get the coding part sorted for you.&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2018 06:55:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861723#M4217</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2018-09-04T06:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861724#M4218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. I will try that way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2018 09:20:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861724#M4218</guid>
      <dc:creator>MortenBjerrum1</dc:creator>
      <dc:date>2018-09-04T09:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861725#M4219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Morten,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you should be able to do it with the standard &lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html"&gt;Enterprise API &lt;/A&gt;with the assign_to_items() command.&lt;/P&gt;&lt;P&gt;That being said, I tried it with different json formats (categories and groupCategories - the second being how it actually is in the json for an item categorized into a group category vs what the example says) and it did not work (always returned "false" response).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you had any luck using the REST API? I have also been trying to categorize items into group categories in python.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2019 21:25:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861725#M4219</guid>
      <dc:creator>AdrienLepoutre</dc:creator>
      <dc:date>2019-11-01T21:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861726#M4220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This can be done with v1.7.1 now.&lt;/P&gt;&lt;P&gt;The Group class has a categories property, that&amp;nbsp;gives you access to the CategorySchemaManager for that group.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can use the .assign_to_items() method to assign group categories to items that belong to the group.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2020 00:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/861726#M4220</guid>
      <dc:creator>JimBarry</dc:creator>
      <dc:date>2020-02-19T00:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Categorize items with the API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/1186546#M7513</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/34"&gt;@JimBarry&lt;/a&gt;&amp;nbsp;this worked for me.&amp;nbsp; I included a general example of what I did in case anybody is interested.&amp;nbsp; The documentation for the&lt;STRONG&gt; assign_to_items()&lt;/STRONG&gt; method shows the function call with a JSON array of item objects - 3 in that example.&amp;nbsp; My array is an array of 1, but obviously more efficient to update or assign categories to multiple items at once.&amp;nbsp; I will pursue this from a Pandas Dataframe.&amp;nbsp; I will update or post again once I get to that point.&amp;nbsp; BOTTOM LINE:&amp;nbsp; assigning categories to groups is very doable.&amp;nbsp; FYI - a nice article on the &lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/category-gallery/" target="_self"&gt;Category Gallery Instant App&lt;/A&gt; posted by ESRI's own&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3072"&gt;@BernSzukalski&lt;/a&gt;&amp;nbsp; that inspired me to create Group Categories for organizational purposes specifically for the Category Gallery.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.gis import Group
my_gis = GIS(username = u_name, password = p_word)
# group_id is a string of numbers of text FYI (for those unaware)
group_id = &amp;lt;find itemid for group, i.e. dc74b222222269e9a54f81afaed0066&amp;gt;
# get group
target_group = Group(my_gis, group_id)
# search items (adjust this to find your items)
items = target_group.content.search(query = "owner: &amp;lt;my_agol_username&amp;gt; AND group:{}".format(group_id),item_type="Feature Service", max_items = 125)
# index of 0 is an an example.  Find index for target_item
item = items[0]
# you need item_id # as with group_id above
item_id = item.item_id
# category = transportation in this example
json_temp = [{item_id: {"categories": ["/Categories/transportation"]}}]
target_group.categories.assign_to_items(json_temp)&lt;/LI-CODE&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/34"&gt;@JimBarry&lt;/a&gt;.&amp;nbsp; This worked for me.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 21:51:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/categorize-items-with-the-api/m-p/1186546#M7513</guid>
      <dc:creator>ZacharyUhlmann1</dc:creator>
      <dc:date>2022-06-26T21:51:01Z</dc:date>
    </item>
  </channel>
</rss>

