关于通过GET /deals/v1/deal/paged获取指定日期范围成交及排序支持的咨询
Hey there! Let me walk you through how to handle both of your requests with the HubSpot Deals API:
To pull only deals where the closedate falls between 2018-01-01 and 2018-01-31, you'll use filter parameters in your GET request. The API lets you chain multiple filters using property, operator, and value query params.
Here's how to structure it:
- Use two separate filter sets for the start and end of your date range:
- For the start date (2018-01-01), use
operator=GTE(greater than or equal to) with the ISO 8601 formatted date (include the time and UTC timezone to avoid ambiguity) - For the end date (2018-01-31), use
operator=LTE(less than or equal to) with the end-of-day timestamp
- For the start date (2018-01-01), use
A full example request would look like this:
GET /deals/v1/deal/paged?property=closedate&value=2018-01-01T00:00:00Z&operator=GTE&property=closedate&value=2018-01-31T23:59:59Z&operator=LTE
If you only want to return specific fields (instead of all deal properties), add additional property params for the fields you need. For example, to get just the deal ID and closedate:
GET /deals/v1/deal/paged?property=dealId&property=closedate&value=2018-01-01T00:00:00Z&operator=GTE&property=closedate&value=2018-01-31T23:59:59Z&operator=LTE
Absolutely! You can sort the results using two query parameters:
sortBy: Specify the property you want to sort by (e.g.,closedate,dealname)sortDir: Define the sort direction—useASCfor ascending order (oldest to newest dates) orDESCfor descending order (newest to oldest)
To combine filtering and sorting, just append these params to your request. For example, to get the filtered deals sorted by closedate in descending order:
GET /deals/v1/deal/paged?property=closedate&value=2018-01-01T00:00:00Z&operator=GTE&property=closedate&value=2018-01-31T23:59:59Z&operator=LTE&sortBy=closedate&sortDir=DESC
内容的提问来源于stack exchange,提问作者JeeShen Lee

