<?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: Get all contacts doesn't get all contacts in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229344#M8240</link>
    <description>&lt;P&gt;Hello, just wanted to give an update:&lt;/P&gt;
&lt;P&gt;I solved the problem by changing the list number. I used to use this url:&lt;BR /&gt;
&lt;A href="https://api.hubapi.com/contacts/v1/lists/180/contacts/all?hapikey=%5BHERE-IS-MY-API-KEY%5D&amp;amp;count=100&amp;amp;property=choose_chapter" class="onebox" target="_blank" rel="nofollow noopener"&gt;https://api.hubapi.com/contacts/v1/lists/180/contacts/all?hapikey=[HERE-IS-MY-API-KEY]&amp;amp;count=100&amp;amp;property=choose_chapter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Instead I now use following url:&lt;BR /&gt;
&lt;A href="https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=%5BHERE-IS-MY-API-KEY%5D&amp;amp;count=100&amp;amp;property=choose_chapter" class="onebox" target="_blank" rel="nofollow noopener"&gt;https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=[HERE-IS-MY-API-KEY]&amp;amp;count=100&amp;amp;property=choose_chapter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I changed the '180' to 'all'&lt;/P&gt;
&lt;P&gt;This solved my problem.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Nov 2018 11:58:38 GMT</pubDate>
    <dc:creator />
    <dc:date>2018-11-14T11:58:38Z</dc:date>
    <item>
      <title>Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229339#M8235</link>
      <description>&lt;P&gt;Hello. I am developing a site for a club which have several franchises called "chapters" around the world. We have our members stored as contacts in Hubspot, who all have a property called "choose_chapter", which represents what chapter that they are in.&lt;/P&gt;
&lt;P&gt;I need to write a script that figures out how many members each chapter has. It does this by scrolling through all members and counting how many are in each chapter. The only problem is that no matter what I do, I will get a lesser number compared to what I see in Hubspot's webapp. An example would be that I get 9 member in a specific chapter when I expect 22.&lt;/P&gt;
&lt;P&gt;Here is my code (in python)&lt;BR /&gt;
import requests&lt;BR /&gt;
import requests&lt;BR /&gt;
import json&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;dict = {}

def get_new(vid_offset):
	url = 'https://api.hubapi.com/contacts/v1/lists/180/contacts/all?hapikey=[HERE-IS-MY-API-KEY]&amp;amp;count=100&amp;amp;property=choose_chapter&amp;amp;vidOffset='+str(vid_offset)
	response = requests.get(url)
	json = response.json()
	for i in json["contacts"]:
		try:
			chapter = i["properties"]['choose_chapter']['value']
			try:
				formercount = dict[chapter]
			except KeyError:
				dict[chapter] = 0
			dict[chapter] += 1
		except KeyError:
			pass
	if (response.json()["vid-offset"] &amp;gt; vid_offset):
		vid_offset = response.json()["vid-offset"]
		get_new(vid_offset)

get_new(0)
print(dict)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 10:46:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229339#M8235</guid>
      <dc:creator />
      <dc:date>2018-11-06T10:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229340#M8236</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/rasmus_hag_lovstad"&gt;@Rasmus_Hag_Lovstad&lt;/A&gt;, happy to help here - can you reply with the portal ID you're trying to get this info from?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 16:51:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229340#M8236</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-11-07T16:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229341#M8237</link>
      <description>&lt;P&gt;Not sure if this is what you're looking for, but 596010&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 17:05:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229341#M8237</guid>
      <dc:creator />
      <dc:date>2018-11-07T17:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229342#M8238</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/rasmus_hag_lovstad"&gt;@Rasmus_Hag_Lovstad&lt;/A&gt;,  I don't see any reason why the endpoint would not return the correct number of contacts with that property. I'm going to continue to do some testing and see if there's anything that might be wrong with the &lt;CODE&gt;vid-offset&lt;/CODE&gt;/ &lt;CODE&gt;has-more&lt;/CODE&gt; fields. Thanks for your patience!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 16:37:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229342#M8238</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-11-08T16:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229343#M8239</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/rasmus_hag_lovstad"&gt;@Rasmus_Hag_Lovstad&lt;/A&gt;, Apologies for the delay, this one slipped through the cracks. Taking a look at the vid offsets and using the new one returned to me in each subsequent request, I was able to page through all of my contacts manually in my own HubSpot Account. I found that the same number of contacts in the UI with a certain value were also being returned back to me correctly through the API. There doesn't appear to be an issue with the vidOffset, but it's likely something to do with the implementation aspect.&lt;/P&gt;
&lt;P&gt;I wish I were able to speak specifically to python implementation, but I'm more familiar with NodeJS, and was able to create a program that will run through a portal, check a custom property, then push those items to an array which then gets sent to a logger. I tested this tool on your portal, and was able to get 16 results for the &lt;CODE&gt;choose_chapter&lt;/CODE&gt; property being equal to "Cambridge". I also was returned 51 contacts for "Berlin", both of which are correct values.&lt;/P&gt;
&lt;P&gt;If you're curious, here's my repo: &lt;A href="https://github.com/cbarley10/hubspot-pagination/blob/master/app.js"&gt;https://github.com/cbarley10/hubspot-pagination/blob/master/app.js&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;One thing in terms of your code that you may want to watch out for is that &lt;CODE&gt;vids&lt;/CODE&gt; are random and non-sequential. It looks like you may be comparing vids to say if if the response's vid offset is greater than the current offset, then to get a new value, but you should really be checking against the &lt;CODE&gt;has-more&lt;/CODE&gt; property being &lt;CODE&gt;true&lt;/CODE&gt; or &lt;CODE&gt;false&lt;/CODE&gt;. If &lt;CODE&gt;has-more&lt;/CODE&gt; is true, you should make another GET request to the endpoint with the returned vidOffset. If &lt;CODE&gt;has-more&lt;/CODE&gt; is false, you're done paging and should return all of your data.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 03:52:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229343#M8239</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-11-14T03:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229344#M8240</link>
      <description>&lt;P&gt;Hello, just wanted to give an update:&lt;/P&gt;
&lt;P&gt;I solved the problem by changing the list number. I used to use this url:&lt;BR /&gt;
&lt;A href="https://api.hubapi.com/contacts/v1/lists/180/contacts/all?hapikey=%5BHERE-IS-MY-API-KEY%5D&amp;amp;count=100&amp;amp;property=choose_chapter" class="onebox" target="_blank" rel="nofollow noopener"&gt;https://api.hubapi.com/contacts/v1/lists/180/contacts/all?hapikey=[HERE-IS-MY-API-KEY]&amp;amp;count=100&amp;amp;property=choose_chapter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Instead I now use following url:&lt;BR /&gt;
&lt;A href="https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=%5BHERE-IS-MY-API-KEY%5D&amp;amp;count=100&amp;amp;property=choose_chapter" class="onebox" target="_blank" rel="nofollow noopener"&gt;https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=[HERE-IS-MY-API-KEY]&amp;amp;count=100&amp;amp;property=choose_chapter&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I changed the '180' to 'all'&lt;/P&gt;
&lt;P&gt;This solved my problem.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 11:58:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229344#M8240</guid>
      <dc:creator />
      <dc:date>2018-11-14T11:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Get all contacts doesn't get all contacts</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229345#M8241</link>
      <description>&lt;P&gt;Ah! Don't know how that slipped by me. I didn't notice it in your URL at first. Glad you were able to get it solved!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 15:16:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Get-all-contacts-doesn-t-get-all-contacts/m-p/229345#M8241</guid>
      <dc:creator>cbarley</dc:creator>
      <dc:date>2018-11-14T15:16:11Z</dc:date>
    </item>
  </channel>
</rss>

