fastify-xhubspot
deals.search
Search HubSpot deals by matching a single property with an equality filter.
deals.search
Search HubSpot deals where a property equals a given value. Returns up to 100 results.
Signature
fastify.deals.search(
property: string,
value: string | number
): Promise<Array<{ id: string; properties: Record<string, string> }>>
Params
| Name | Type | Required | Description |
|---|---|---|---|
property | string | Yes | HubSpot property name to filter on (e.g., "dealstage", "pipeline"). |
value | string | number | Yes | Value to match. Converted to string before the API call. |
Returns
Array of { id, properties }. Empty if no matches.
Throws
[xHubspot] deals.search requires a property string[xHubspot] deals.search requires a value- Re-throws HubSpot API errors.
Examples
Find all open deals
const open = await fastify.deals.search("dealstage", "qualifiedtobuy");
Realistic — revenue report
fastify.get("/reports/closed-won", async () => {
const deals = await fastify.deals.search("dealstage", "closedwon");
const total = deals.reduce((sum, d) => sum + Number(d.properties.amount || 0), 0);
return { count: deals.length, totalAmount: total };
});
See also
- deals.list — list all deals without a filter
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.deals.search(propertyName, value, options?)
use-when: Filter HubSpot deals by a single property value
returns: { results, total }
