<?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: Using Jupyter Notebooks to search for all items that contain a specific feature service? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1384462#M57566</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&amp;nbsp; Can you share this notebook again?&amp;nbsp; looks like that link requires credentials to your org now&lt;/P&gt;</description>
    <pubDate>Tue, 20 Feb 2024 17:13:17 GMT</pubDate>
    <dc:creator>Tim_Shapiro</dc:creator>
    <dc:date>2024-02-20T17:13:17Z</dc:date>
    <item>
      <title>Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275325#M51273</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a Python script within Jupyter Notebooks that will allow me to search all publicly available items within ArcGIS online that contain a specific feature service. Here is the script I have so far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcgis
from arcgis.gis import GIS

# connect to ArcGIS Online
gis = GIS("https://www.arcgis.com")
feature_service_id = "FEATURE SERVICE ID"
print('connected to arcgis online')

# search for all publicly available feature services
web_maps = gis.content.search(query= feature_service_id, item_type = 'web map', outside_org=True, max_items = 200)
print('Found public items')

# print the titles of the feature services
for item in web_maps:
    print('NAME: ' + item.title,'OWNER: ' + item.owner)
print('completed')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cant seem to figure out how to return the webmaps that contain the feature service specified. Any help is appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:47:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275325#M51273</guid>
      <dc:creator>DaveK</dc:creator>
      <dc:date>2023-04-04T15:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275338#M51274</link>
      <description>&lt;P&gt;To find instances of the feature service, you need to look at the JSON definition of the maps and look for a matching URL. You might also want to look through public &lt;EM&gt;apps&lt;/EM&gt;, as a web app can reference the layer through a widget, and this would not show up in the map configuration.&lt;/P&gt;&lt;P&gt;Here's a notebook I wrote up for this exact kind of thing!&lt;/P&gt;&lt;P&gt;&lt;A href="https://kendall.maps.arcgis.com/home/notebook/notebook.html?id=2967bae3767640038a6841714784d44c" target="_blank"&gt;https://kendall.maps.arcgis.com/home/notebook/notebook.html?id=2967bae3767640038a6841714784d44c&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 16:24:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275338#M51274</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-04-04T16:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275341#M51275</link>
      <description>&lt;P&gt;Hey Dave,&lt;/P&gt;&lt;P&gt;Does adding &lt;EM&gt;display (web_maps)&lt;/EM&gt; to the end of your code return the desired result?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 16:27:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275341#M51275</guid>
      <dc:creator>David_McRitchie</dc:creator>
      <dc:date>2023-04-04T16:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275440#M51280</link>
      <description>&lt;P&gt;Great script&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;! There are a few additional, common use cases one might want to check on too:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Insights Workbooks (which you should be able to add to the list of Web Apps in your script.)&lt;/LI&gt;&lt;LI&gt;Views, Service Definitions, Exports, etc. related to the feature service, which can be retrieved with related_items().&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Survey123 Forms and their feature service, which can be retrieved with get_data() and in the zip looking for the feature service reference in the form.info file.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It isn't really feasible for a brute force scripting approach to identify all the possible dependencies, however, it can cover the most common use cases fairly well. What will get overlooked are edge cases like a Notebook or an Arcade Expression in a Web Map or Dashboard, where a feature service reference is generated programmatically, rather than coded into searchable text with an explicit item ID or feature service URL.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 19:13:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275440#M51280</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2023-04-04T19:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275450#M51281</link>
      <description>&lt;P&gt;Great suggestions! Arcade should still be caught, though, as the expression text gets saved into the JSON of the map or dashboard. A layer used by Arcade is either part of the same service ($datastore or relationship class), another layer in the map ($map), or else it's brought in via the FeatureSetByPortalItem function, in which the service itemID is a parameter, so it's searchable. Probably need to tweak the code to account for this, though...&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 19:23:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275450#M51281</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-04-04T19:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275499#M51285</link>
      <description>&lt;P&gt;Most of the common Arcade use cases would have an explicit item ID or feature service URL present in the code. We have some edge cases, however, where the portal URL and item ID value passed to FeatureSetByPortalItem are programmatically retrieved from another feature service for abstraction reasons, hence there is no hardcoded item ID to be searched for in the Arcade code. Trying to develop a script that covers all potential possibilities doesn't seem feasible.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 20:10:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275499#M51285</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2023-04-04T20:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275753#M51302</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;.,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for supplying this notebook! After inputting a service ID and running it I did get some inaccurate results. I tried the script with an item in my content that is within a single webmap. The results did not come back with the webmap the service was in and returned other items from my organization. Is there any editing I need to do prior to running this code?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 13:52:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275753#M51302</guid>
      <dc:creator>DaveK</dc:creator>
      <dc:date>2023-04-05T13:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275772#M51305</link>
      <description>&lt;P&gt;Interesting... Well, are you able to share the ItemID? I'd be curious to test this against the actual item of content.&lt;/P&gt;&lt;P&gt;I would suggest looking at the JSON for the "inaccurate" items. Try going to &lt;STRONG&gt;your-org.arcgis.com/sharing/rest/content/items/&amp;lt;itemid&amp;gt;/data?f=json&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Search through that text to see if the itemID or URL appear. You might need a token to hit the URL directly, so you could also use the Notebook to return the actual data JSON of matching items.&lt;/P&gt;&lt;P&gt;I didn't initially do that because of the size of the response, but in the last code cell, we can do this instead:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dependencies = pd.concat(
    [
        pd.DataFrame([{'title':a.title, 'id':a.id, 'type':a.type, 'url':f'{gis.url}/home/item.html?id={a.id}', 'data':a.get_data()} for a in app_list]),
        pd.DataFrame([{'title':m.title, 'id':m.id, 'type':m.type, 'url':f'{gis.url}/home/item.html?id={m.id}', 'data':m.get_data()} for m in map_list])
    ]
)

dependencies.head()&lt;/LI-CODE&gt;&lt;P&gt;Then if there's an item in the output that you consider inaccurate, call it by index:&lt;/P&gt;&lt;PRE&gt;dependencies.loc[3,'data']&lt;/PRE&gt;&lt;P&gt;This will show you the full definition of the map / app, and if your service appears in it, you'll be able to find it.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 14:10:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1275772#M51305</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-04-05T14:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1384462#M57566</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&amp;nbsp; Can you share this notebook again?&amp;nbsp; looks like that link requires credentials to your org now&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 17:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1384462#M57566</guid>
      <dc:creator>Tim_Shapiro</dc:creator>
      <dc:date>2024-02-20T17:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1385093#M57604</link>
      <description>&lt;P&gt;No idea what changed about AGOL's notebook sharing, but here's a Github Gist w/ the same stuff in it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://gist.github.com/jdcarls2/717f79ff12a4a1cb337dafe8e76c70df" target="_blank"&gt;https://gist.github.com/jdcarls2/717f79ff12a4a1cb337dafe8e76c70df&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 19:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1385093#M57604</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-02-21T19:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using Jupyter Notebooks to search for all items that contain a specific feature service?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1385221#M57611</link>
      <description>&lt;P data-unlink="true"&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/618448"&gt;@Tim_Shapiro&lt;/a&gt;&amp;nbsp;the notebook is shared with everyone, however, the link provided is for running the Notebook. That means ArcGIS needs to check that you have to have the ability to run Notebooks on an ArcGIS Online organization, so you get directed to an authentication workflow.&lt;/P&gt;&lt;P data-unlink="true"&gt;The workaround is to provide a URL to the Notebook's Overview tab on its Item Details page, which doesn't require any special privileges. You also need to use &lt;A href="http://www.arcgis.com," target="_blank"&gt;www.arcgis.com,&lt;/A&gt;&amp;nbsp;instead of your own org, kendall.maps.arcgis.com.&lt;/P&gt;&lt;P data-unlink="true"&gt;Try&amp;nbsp;this URL to access the notebook:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.arcgis.com/home/item.html?id=2967bae3767640038a6841714784d44c#overview" target="_self"&gt;https://www.arcgis.com/home/item.html?id=2967bae3767640038a6841714784d44c#overview&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This permits anyone to Preview or Download the Notebook, even if they don't have permission to run Notebooks on their own ArcGIS Online org.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 01:19:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/using-jupyter-notebooks-to-search-for-all-items/m-p/1385221#M57611</guid>
      <dc:creator>PeterKnoop</dc:creator>
      <dc:date>2024-02-22T01:19:35Z</dc:date>
    </item>
  </channel>
</rss>

