X Enterprises
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

NameTypeRequiredDescription
objectTypestringYesThe custom object type name or ID (e.g., "subscriptions", "2-12345").
options.limitnumberNoMaximum number of records to return per page. Default: 100.
options.afterstringNoCursor token from a previous response paging.next.after to fetch the next page.

Returns

FieldTypeDescription
objectsArray<{ id, properties }>The records on the current page.
pagingobject | nullPagination info. paging.next.after is the cursor for the next page; null when no more pages.

Throws

  • [xHubspot] customObjects.list requires an objectType — if objectType is 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

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 }
Copyright © 2026