fastify-xhubspot
customObjects.list
List all records for a HubSpot custom object type with optional pagination.
customObjects.list
List records for a given HubSpot custom object type. Supports cursor-based pagination via limit and after.
Signature
fastify.customObjects.list(
objectType: string,
options?: { limit?: number; after?: string }
): Promise<{
objects: Array<{ id: string; properties: Record<string, string> }>;
paging: { next?: { after: string } } | null;
}>
Params
| Name | Type | Required | Description |
|---|---|---|---|
objectType | string | Yes | The custom object type name or ID (e.g., "subscriptions", "2-12345"). |
options.limit | number | No | Maximum number of records to return per page. Default: 100. |
options.after | string | No | Cursor token from a previous response paging.next.after to fetch the next page. |
Returns
| Field | Type | Description |
|---|---|---|
objects | Array<{ id, properties }> | The records on the current page. |
paging | object | null | Pagination info. paging.next.after is the cursor for the next page; null when no more pages. |
Throws
[xHubspot] customObjects.list requires an objectType— ifobjectTypeis missing.- Re-throws the HubSpot API error on network failure after logging via
fastify.log.error.
Examples
Basic — list the first page
const { objects, paging } = await fastify.customObjects.list("subscriptions");
console.log(objects.length); // up to 100
console.log(paging?.next?.after); // cursor for next page, or undefined
Realistic — paginate through all records
fastify.get("/subscriptions", async (request, reply) => {
const { limit = 20, after } = request.query;
const result = await fastify.customObjects.list("subscriptions", {
limit: Number(limit),
after,
});
return reply.send({
items: result.objects,
nextCursor: result.paging?.next?.after ?? null,
});
});
See also
- customObjects.search — filter records by a property value
- customObjects.getById — fetch a single record by ID
- customObjects.batchCreate — create multiple records at once
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.customObjects.list(objectTypeId, options?)
use-when: Page through all records of a custom object type
returns: { results, paging }
