How can I fetch multiple pages of results automatically?

Return to top


  • Seneca Spurling

    It seems that CURLOPT_SSL_VERIFYHOST now needs to be set to 2.

    If you don't already have php-curl installed, you'll need that package as well.

    If you run it and get a zero-length output file, try changing the $end_page to 2. If you ask for a page that doesn't exist it overwrites the file with nothing at all. However it seems to handle things correctly up to then. You get 100 records per page, so for example if you have 650 records, you'll need to set $end_page to 6.
    If you're getting organizations, for example, you can use something like this to get the count so you know how many pages to get. The count may not be accurate over 100,000. See

    curl https://{subdomain} \
      -v -u {email_address}:{password}

    I know this is just an example and not meant to be robust. This isn't a complaint or request for changes, just adding these comments here in case they help someone like myself in the future. 

  • Brett Bowser
    Zendesk Community Manager

    Thanks for taking the time to share this with everyone Seneca :)


Please sign in to leave a comment.

Powered by Zendesk