Use Case: Retrieve al deals that created at January 2020.
I found 2 ways to retrieve deals:
1. Get all deals with /crm/v3/objects/deals
2. Use search /crm/v3/objects/deals/search with sorting by createdate to get last 10,000 deals.
Both are not good enough. Request all every time that I want to update my data is wasteful and blast the API, and the last 10,000 may not include the requested date range.
Is there an option to retrieve deals by date range?
I think the solution could be under the Search method.
If you will support createdate as a searchable property
the search method will be extremely powerful.
Is this on the table?
Hey @PowerMyAnalytic
I can confirm that we do indeed support createdate as a property that can be used to refine search queries via our CRM Search API.
See below for an example:
Request URL:
POST https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY
Payload:
{
"filterGroups":[
{
"filters":[
{
"propertyName": "createDate",
"operator": "GTE",
"value": "INSERT_TIMESTAMP_IN_MILLISECONDS"
}
]
}
]
}
An example for the timestamp of one of my deals, the UI displays: 02/19/2020, converting to milliseconds, I get 1582070400000.
Using this in my request, I get the following response:
{
"total": 1,
"results": [
{
"id": "1592369832",
"properties": {
"amount": null,
"closedate": "2020-02-29T10:00:02.147Z",
"createdate": "2020-02-19T10:00:02.147Z",
"dealname": "API Line Item Deal",
"dealstage": "c51cd404-82cc-4c1c-9d95-a8a89f125251",
"hs_lastmodifieddate": "2020-03-18T08:55:09.356Z",
"hs_object_id": "1592369832",
"pipeline": "default"
},
"createdAt": "2020-02-19T10:00:02.147Z",
"updatedAt": "2020-03-18T08:55:09.356Z",
"archived": false
}
]
}
I hope this helps!
Hi @Willson
Awsome!
But I’m getting error.
Maybe this functionality is not yet exposed to the users?
(no option of filter by time in the Docs Search the CRM - HubSpot docs)
https://api.hubapi.com/crm/v3/objects/deals/search
{
"filterGroups":[
{
"filters":[
{
"propertyName": "createDate",
"operator": "GTE",
"value": 1586476800000
}
]
}
]
}
400 Bad Request error:
{
"status": "error",
"message": "There was a problem with the request.",
"correlationId": "c0fa743e-1d52-4978-a4d6-ecd1283c2924"
}
Hey @PowerMyAnalytic
Looking through your filter, I can see that create date is showing as createDate. Could we try with createdate as this is case sensitive.
Thanks!
@PowerMyAnalytic , Sorry for ressurecting the old question but I have the same problem. And as I can see search endpoint doesn’t suit me well since it can return only 10000 records max and have more strict rate limits.
What if I want to get ALL records starting from Jan 1, 2021 even if there are 20000 records?
The option I use know is to list all the records and later filter the results but it’s not optimal neither for our customers since waiting time becomes longer nor for your servers, I believe
Thank you