Retrieve Contact Information from HubSpot

In this example, we use the Has next field to retrieve the list of users created most recently in HubSpot, and then separate the user information from other details in the API response.


REST Get Pipeline

Download this Pipeline

The following steps describe how to retrieve contact details from HubSpot using REST Get and JSON Splitter Snaps.

  1. Configure the REST Get Snap to retrieve user information from HubSpot

    Configure the REST Get Snap without the pagination details (Has Next and Next URL fields).


    REST Get configuration

  2. Validate the Snap. After validation, the Snap displays the output with only 20 records and shows the has-more value as true, indicating that there are more records available.
    REST Get Output

  3. Configure the Has Next and Next URL fields:

    REST Get configuration

    REST Get configuration details: The following configuration details are key to understanding this example:
    Field Value Description
    Service URL https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=demo This is a demo API offered by HubSpot, which returns details of all contacts created in the demo account in descending order. This API only scrolls back 30 days in time.
    Has next $entity['has-more'] The REST Get Snap lists 20 documents by default. If more contacts were created during the previous 30 days, this API returns true for the key has-more.
    Next URL "https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=demo&vidOffset=" + $entity['vid-offset'] This URL retrieves the next set of 20 documents. In this URL, vid-offset is the ID of the last user retrieved in the preceding call. For example, if the last user ID in the response is 12345, that becomes the value of the vid-offset parameter.

    Execute the Snap—it lists out API response entities in sets of 20, until the last contact information is listed out, and the has-more field changes to false:


    REST Get configuration


    REST Get Output

  4. Configure the JSON Splitter Snap. The output from the REST Get Snap contains several details. To extract only the user details (available in the entity.contacts array), configure the JSON Splitter Snap to isolate the required information.
    REST Splitter overview

    The output from the JSON Splitter Snap contains only the contact information you need.


    REST Splitter overview