[Answer]-Retrieve all contacts from gmail using python

1👍

As the Contacts API documentation says:

The Contacts API has a hard limit to the number of results it can return at a time even if you explicitly request all possible results. If the requested feed has more fields than can be returned in a single response, the API truncates the feed and adds a “Next” link that allows you to request the rest of the response.

So you’ll have to page through the contacts, following those “Next” links, until you have all the contacts (which you can detect by looking for a result without a ‘Next’ link).

If you don’t want to do extra parsing, you could try using the start-index parameter to ask for extra contacts (ie. your program has retrieved 30, so you’ll set start-index to 31 for the next query). That section also suggests you might be able to override the limit on returned results:

If you want to receive all of the contacts, rather than only the default maximum, you can specify a very large number for max-results.

But I wouldn’t be surprised if that was false, and you’ll have to use the paginated approach.

👤Alex P

Leave a comment