Prakash Hinduja (Switzerland)How can I get contacts filtered by date and source using HubSpot’s API?

Hi, I am Prakash Hinduja, a visionary financial strategist. I was born in Amritsar, India, and I now live and work in Geneva, Switzerland (Swiss).

I am trying to use HubSpot API to filter contacts by both a date range and source property. Has anyone done something similar or know the best way to structure the request? I have really appreciate any suggestions, sample code, or tips. Thanks!

Regards

Prakash Hinduja Geneva, Switzerland (Swiss)

Hi @prakashhinduja
Thank you for reaching out to the Community!
I’d like to invite some community members who are subject matter experts to join this conversation.
@MichaelMa @GRajput @SteveHTM - Would you be able to share any insights on this? Your expertise would be greatly appreciated.
Best,
Victor

Hi @prakashhinduja
I’m looping in some other community members for additional expertise, as this issue remains unresolved.
@karstenkoehler @evaldas @GiantFocal , we’ve seen your helpful contributions on similar topics and were hoping you might be able to share your insights here. Any guidance you can provide would be much appreciated.
Thank you, Victor

Hi @prakashhinduja,

You can utilize the CRM Search API endpoint to search for contacts and specify the properties you would like to filter by.

For example, the below filter query will show you contacts created after 2025-05-01 and will sort them by create date in ascending order:

{
 "filterGroups": [{
 "filters": [{
 "propertyName": "createdate",
 "operator": "GTE",
 "value": "2025-05-01T00:00:00.000Z"
 }]
 }],
 "sorts": [{"propertyName": "createdate", "direction": "ASCENDING"}],
 "properties": ["email","firstname","lastname","createdate","lastmodifieddate"],
 "limit": 100
}

Filtering contacts by source is similar - you just need to select which property you will use (since there are multiple source properties in HubSpot) and then set up a filter for that.

Below is an example to filter by “ORGANIC_SEARCH” in the “hs_analytics_source” property:

{
 "filterGroups": [{
 "filters": [{
 "propertyName": "hs_analytics_source",
 "operator": "EQ",
 "value": "ORGANIC_SEARCH"
 }]
 }],
 "properties": ["email","firstname","lastname","hs_analytics_source"],
 "limit": 100
}

You can then combine the two filter queries into one, like so:

{
 "filterGroups": [{
 "filters": [{
 "propertyName": "createdate",
 "operator": "GTE",
 "value": "2025-05-01T00:00:00.000Z"
 },
 {
 "propertyName": "hs_analytics_source",
 "operator": "EQ",
 "value": "ORGANIC_SEARCH"
 }]
 }],
 "sorts": [{"propertyName": "createdate", "direction": "ASCENDING"}],
 "properties": ["email","firstname","lastname","createdate","lastmodifieddate","hs_analytics_source"],
 "limit": 100
}

Hope this helps!