APIs & Integrations

saar1
Member

API call - hot to call a list i've created

Hi there, i was wondering how can i retrieve a specific contact list i’ve created via an API call. Thanks

0 Upvotes
11 Replies 11
Not applicable

API call - hot to call a list i've created

Hi @kfischmann,

I am running into something similar just looking for more clarification.
My end user maintains a list.
This list contains a subset of properties which we need to return for a specific manual workflow.
I have been tasked with creating an app to return the recent contacts from this list with only those specific properties. (The returned properties will not be static. Properties can be added and removed by the end user.)

When I run the service described here: https://developers.hubspot.com/docs/methods/lists/get_list_contacts_recent
I only return three or four of the properties being stored in the list:

From your above comments this is expected. ***If this is correct why is not documented in the SDK.
"
Property &property=X - Used in the request URL If you include the “property” parameter, then the properties in the “contact” object in the returned data will only include the property or properties that you request.
"
The above entry would lead me to believe all of the properties would be returned unless explicitly listed.

If I understand your response above:
“Thanks for the clarification. There isn’t a single endpoint which will give you a single object with all relevant contact properties. What you’d need to do is :

  1. Get the ID of the list in question from one of the GET endpoints within the Contact Lists API, such as ‘Get dynamic contact lists2’
  2. Get the list of contacts from the ‘Get contacts in a list’ endpoint
  3. Call the ‘Get group of contacts by ID1’ endpoint, feeding in the VIDs of the relevant contacts as URL parameters (&vid=xxx&vid=xxx…). You’re also able to stipulate which properties the returned object will contain (&property=x&property=y…), bearing in mind that there will be some default properties regardless of the properties included in the call. Up to 100 contacts can be returned at a time using this endpoint
  4. At the end of each request to the batch contacts API, add the returned contact objects to your main ‘list’ object
    I hope this is of assistance. Let me know if you encounter any issues.”

The workflow would be to use the aforementioned service to return the recent contact’s vids. Then use the contacts service to return all of the properties tied to that contact. How do I limit the property values to only what is being selected by the end user in the list?

Thanks in advance,

Paul

0 Upvotes
kfischmann1
Member

API call - hot to call a list i've created

Hi @saar1,

To get a specific list, you first need to know its listId. You can access a list of all your lists by hitting the ‘Get a set of contact lists’ endpoint. You can then call either the ‘Get a contact list by ID’ endpoint to receive metadata about the list, or the ‘Get contacts in a list’ to get the contacts within a list, including the relevant listId within the call.

Let me know if you require further assistance.

0 Upvotes
saar1
Member

API call - hot to call a list i've created

Hi tnx for getting back to me.
What i’m looking for is NOT the metadata of a list i’ve created, but the actual table with ALL values and information.
How do i do that with an API call?

0 Upvotes
saar1
Member

API call - hot to call a list i've created

And i mean not only the information about the contacts, but all of the fields within this list

0 Upvotes
kfischmann1
Member

API call - hot to call a list i've created

@saar1,

What is the use case you’re attempting to solve here?

The two endpoints mentioned are designed to give you this information; ‘Get a contact list by ID’ will give you the metadata about the given list, and ‘Get contacts in a list’ will return the contacts contained within the list. I’m unclear about what you’re referring to when you say ‘all of the fields within this list’ - Are you referring to the conditions specified for segmentation in the case that the list is a smart list?

Also, worth noting that the HubSpot API uses JSON as its data payload - all responses containing data will be delivered as JSON objects.

0 Upvotes
saar1
Member

API call - hot to call a list i've created

Sorry ill make myself clear.
I’ve created a list. In that list there are several properties (in which i chose to have in).
So far, from what i saw. i can only get the metadata of this list, or to get the list of the contacts in that list.
My question is, what API i can make in order to receive all of the table, meaning all columns and their value as a JSON object. To clarify more - if the list looks something like this:

I want to get all the information and values for this list (including the ‘red’, ‘blue’ etc) as a JSON object

Clear enough?
Tnx

0 Upvotes
kfischmann1
Member

API call - hot to call a list i've created

@saar1,

Thanks for the clarification. There isn’t a single endpoint which will give you a single object with all relevant contact properties. What you’d need to do is ::

  1. Get the ID of the list in question from one of the GET endpoints within the Contact Lists API, such as ‘Get dynamic contact lists
  2. Get the list of contacts from the ‘Get contacts in a list’ endpoint
  3. Call the ‘Get group of contacts by ID’ endpoint, feeding in the VIDs of the relevant contacts as URL parameters (&vid=xxx&vid=xxx…). You’re also able to stipulate which properties the returned object will contain (&property=x&property=y…), bearing in mind that there will be some default properties regardless of the properties included in the call. Up to 100 contacts can be returned at a time using this endpoint
  4. At the end of each request to the batch contacts API, add the returned contact objects to your main ‘list’ object

I hope this is of assistance. Let me know if you encounter any issues.

0 Upvotes
saar1
Member

API call - hot to call a list i've created

Tnx for getting back to me.
How can i overcome the limit of contacts in the API call?
My final goal is to create an automatic API call everyday and manipulate it after using Python script but i have a lot of contacts…

0 Upvotes
saar1
Member

API call - hot to call a list i've created

I mean the limit of the returned number of contacts

0 Upvotes
kfischmann1
Member

API call - hot to call a list i've created

Hi @saar1,

You’ll need to take a divide and conquer approach here, as the maximum returnable contacts in any one request is 100. Iterate through the list of returned contacts from the ‘Get contacts in a list’ call and call the ‘Get group of contacts by id’ endpoint with each group of 100 vids or part thereof.

0 Upvotes
saar1
Member

API call - hot to call a list i've created

How could i be sure that i won’t have duplications / contacts i have not
received at all?

0 Upvotes