X Enterprises
fastify-xhubspot

contacts.list

Page through all HubSpot contacts with optional limit and cursor-based pagination.

contacts.list

Retrieve a paginated list of HubSpot contacts. Uses cursor-based pagination via the after token returned in each response.

Signature

fastify.contacts.list(options?: {
  limit?: number;
  after?: string;
  sort?: string[];
}): Promise<{
  contacts: Array<{ id: string; properties: Record<string, string> }>;
  paging?: { next?: { after: string } };
}>

Params

NameTypeRequiredDescription
options.limitnumberNoMaximum contacts per page. Default: 100.
options.afterstringNoCursor token from a previous response's paging.next.after to get the next page.
options.sortstring[]NoSort order, e.g., ["-createdate"] for descending by creation date.

Returns

FieldTypeDescription
contactsArray<{ id, properties }>Contacts on this page.
paging.next.afterstring | undefinedCursor for the next page. Absent when there are no more pages.

Throws

Re-throws the HubSpot API error on failure.

Examples

Basic — first page

const { contacts, paging } = await fastify.contacts.list({ limit: 50 });

for (const contact of contacts) {
  console.log(contact.id, contact.properties.email);
}

Realistic — paginate all contacts

async function getAllContacts(fastify) {
  const all = [];
  let after;

  do {
    const result = await fastify.contacts.list({ limit: 100, after });
    all.push(...result.contacts);
    after = result.paging?.next?.after;
  } while (after);

  return all;
}

See also

AI Context

package: "@xenterprises/fastify-xhubspot"
method: fastify.contacts.list(options?)
use-when: Page through all HubSpot contacts with optional limit, after cursor, and properties list
returns: { results, paging }
Copyright © 2026