<?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 AGOL Arcpy count features in a hosted services from REST in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417548#M32800</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to get the&amp;nbsp;total count of features in a single service with python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Dec 2019 18:38:53 GMT</pubDate>
    <dc:creator>JordanMiller4</dc:creator>
    <dc:date>2019-12-09T18:38:53Z</dc:date>
    <item>
      <title>AGOL Arcpy count features in a hosted services from REST</title>
      <link>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417548#M32800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to get the&amp;nbsp;total count of features in a single service with python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2019 18:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417548#M32800</guid>
      <dc:creator>JordanMiller4</dc:creator>
      <dc:date>2019-12-09T18:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Arcpy count features in a hosted services from REST</title>
      <link>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417549#M32801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See: &lt;A href="https://developers.arcgis.com/rest/services-reference/query-feature-service-.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Query (Feature Service)&lt;/A&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The Query operation is performed on a feature service resource. The result of this operation is either a feature set for each layer in the query or a count of features for each layer (if &lt;SPAN&gt;returnCountOnly&lt;/SPAN&gt; is set to &lt;SPAN&gt;true&lt;/SPAN&gt;) or an array of feature IDs for each layer in the query (if &lt;SPAN&gt;returnIdsOnly&lt;/SPAN&gt; is set to &lt;SPAN&gt;true&lt;/SPAN&gt;).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I did a quick test, with returnCountOnly set to true and using a where "1=1". It returned a count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;URL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"https://services.arcgis.com/xxxxx/arcgis/rest/services/myFeature/FeatureServer/0/query"&lt;/SPAN&gt;

query_dict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"where"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"1=1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"returnCountOnly"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"true"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"returnGeometry"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"false"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"f"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"json"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"token"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; token&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'token'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

jsonResponse &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlopen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;URL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlencode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query_dict&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

response &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; json&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;loads&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;jsonResponse&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; response

&lt;SPAN class="comment token"&gt;# prints: {u'count': 486, u'serverGens': {u'serverGen': 461482, u'minServerGen': 65364}}&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;/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>Sat, 11 Dec 2021 18:53:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417549#M32801</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T18:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: AGOL Arcpy count features in a hosted services from REST</title>
      <link>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417550#M32802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are using the Python API, see: &lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html#arcgis.features.FeatureLayer.query"&gt;arcgis.features.FeatureLayer.query&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and use&amp;nbsp; return_count_only=True&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2019 03:46:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/agol-arcpy-count-features-in-a-hosted-services/m-p/417550#M32802</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2019-12-10T03:46:20Z</dc:date>
    </item>
  </channel>
</rss>

