<?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: Search standalone server services through ArcGIS API for Python in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044924#M72399</link>
    <description>&lt;P&gt;Perfect! Thank you very much, Josh, this is exactly what I was looking for. I spent so much time this morning to find a solution so this is greatly appreciated! I did play with the ServiceDirectory class but I obviously wasn't using the right syntax.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Tomislav&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 01:16:06 GMT</pubDate>
    <dc:creator>shapo</dc:creator>
    <dc:date>2021-04-08T01:16:06Z</dc:date>
    <item>
      <title>Search standalone server services through ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044864#M72395</link>
      <description>&lt;P&gt;Does anyone know how to search services, such as a Feature Layer, on a standalone ArcGIS server through ArcGIS API for Python? For example, I am trying to access and list services published&amp;nbsp; at&amp;nbsp;&amp;nbsp;&lt;A href="https://geoappext.nrcan.gc.ca/arcgis/rest/services/" target="_blank" rel="noopener"&gt;https://geoappext.nrcan.gc.ca/arcgis/rest/services/&lt;/A&gt;&amp;nbsp;by using gis.content.search but with no luck.&lt;/P&gt;&lt;P&gt;I have been using this code:&lt;/P&gt;&lt;P&gt;gis = GIS()&lt;BR /&gt;items = gis.content.search(query="NRCAN",item_type="Feature Layer", max_items=10000)&lt;/P&gt;&lt;P&gt;I do get some of the services back as items but 'search' casts a too wide net, grabbing services that are not on that server as well, which then due to the max_items cap of 10,000 results in many of the services on the stated server not caught and returned as items. I would like to have only the feature layer services on the stated server returned as items, no other services.&lt;/P&gt;&lt;P&gt;Any help would be much appreciated, thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 21:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044864#M72395</guid>
      <dc:creator>shapo</dc:creator>
      <dc:date>2021-04-07T21:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Search standalone server services through ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044875#M72396</link>
      <description>&lt;P&gt;What you want is the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html#arcgis.gis.server.catalog.ServicesDirectory" target="_self"&gt;&lt;STRONG&gt;ServicesDirectory&lt;/STRONG&gt; &lt;/A&gt;class. With it, you can iterate over the server's folders and return the services.&lt;/P&gt;&lt;P&gt;There &lt;EM&gt;is &lt;/EM&gt;a "find" method, but repeated tests don't return reliable results. There's also a "report" method that returns the services in a folder as a Pandas DataFrame, which sounds ideal, but I haven't gotten that to return anything useful, either.&lt;/P&gt;&lt;P&gt;In any case, you can simply iterate over the entire server and populate a list of services, then search that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis.server.catalog import ServicesDirectory

s = ServicesDirectory('https://geoappext.nrcan.gc.ca/arcgis/rest/services/')

full_list = []

for f in s.folders:
    for svc in s.list(folder=f):
        full_list.append(svc)
    
full_list&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Returns&lt;/P&gt;&lt;PRE&gt;[&amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBCT3978/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBCT_TXT_3857/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBCT_TXT_3978/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBME_CBCE_HS_RO_3978/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBMT3978/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBMT_CBCT_GEOM_3857/MapServer"&amp;gt;,
 &amp;lt;MapImageLayer url:"https://geoappext.nrcan.gc.ca/arcgis/rest/services//BaseMaps/CBMT_CBCT_GEOM_3978/MapServer"&amp;gt;,&lt;BR /&gt;...&lt;/PRE&gt;&lt;P&gt;You can then search through that list for specific items.&lt;/P&gt;&lt;P&gt;Bonus points: use list comprehension to compile the list in one line:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;[svc for sublist in [s.list(f) for f in s.folders] for svc in sublist]&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 07 Apr 2021 21:56:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044875#M72396</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-04-07T21:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Search standalone server services through ArcGIS API for Python</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044924#M72399</link>
      <description>&lt;P&gt;Perfect! Thank you very much, Josh, this is exactly what I was looking for. I spent so much time this morning to find a solution so this is greatly appreciated! I did play with the ServiceDirectory class but I obviously wasn't using the right syntax.&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Tomislav&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 01:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-standalone-server-services-through-arcgis/m-p/1044924#M72399</guid>
      <dc:creator>shapo</dc:creator>
      <dc:date>2021-04-08T01:16:06Z</dc:date>
    </item>
  </channel>
</rss>

