X Enterprises
fastify-xhubspot

companies.list

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

companies.list

Retrieve a paginated list of HubSpot companies.

Signature

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

Params

NameTypeRequiredDescription
options.limitnumberNoMax companies per page. Default: 100.
options.afterstringNoCursor from paging.next.after for the next page.

Returns

{ companies, paging }paging.next.after is absent on the last page.

Throws

Re-throws HubSpot API errors.

Examples

Basic

const { companies } = await fastify.companies.list({ limit: 25 });

Paginate all companies

async function getAllCompanies(fastify) {
  const all = [];
  let after;
  do {
    const result = await fastify.companies.list({ limit: 100, after });
    all.push(...result.companies);
    after = result.paging?.next?.after;
  } while (after);
  return all;
}

See also

AI Context

package: "@xenterprises/fastify-xhubspot"
method: fastify.companies.list(options?)
use-when: Page through all HubSpot companies
returns: { results, paging }
Copyright © 2026