Skip to content

πŸ› getCatalog pagination limited to 50 products & getCollections capped at 20 items per collectionΒ #2589

@kelvinzer0

Description

@kelvinzer0

Problem

I am running a WhatsApp Business catalog with 63+ products across 6 collections. The current Evolution API implementation has critical pagination limitations that prevent fetching all products correctly.


1. getCatalog β€” Auto-pagination limited to 50 products max

File: src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

const limit = data.limit || 10;        // ← Default is only 10!
let countLoops = 0;
while (fetcherHasMore && countLoops < 4) {  // ← Max 4 loops only!
  catalog = await this.getCatalog({ jid, limit, cursor: nextPageCursor });
  // ...
  countLoops++;
}
  • With default limit=10 and max 4 loops β†’ 50 products max
  • Even with limit=50 and 4 loops β†’ 250 products max
  • For catalogs with 250+ products, this is insufficient
  • The WhatsApp binary protocol supports cursor-based pagination via the <after> tag, but the Evolution API does not expose the cursor parameter to users

2. cursor parameter stripped by validation schema

File: src/validate/business.schema.ts

export const catalogSchema = {
  type: "object",
  properties: {
    number: { type: "string" },
    limit: { type: "number" },
    // ⚠️ cursor is MISSING from validation schema!
  },
};

Even though getCatalogDto defines cursor?: string, the validation schema strips it out, so users cannot manually paginate beyond the auto-pagination limit.

3. getCollections β€” Hard cap at 20 items per collection

File: src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

const limit = data.limit <= 20 ? data.limit : 20;  // "tem esse limite, nΓ£o sei porque"
  • Collections with more than 20 products get truncated
  • In my case, both "Seblak" and "Cemilan" collections have exactly 20 products each β€” adding even 1 more product would cause data loss
  • The comment "tem esse limite, nΓ£o sei porque" ("it has this limit, I don't know why") suggests this cap is arbitrary
  • Baileys defaults to limit = 51 for getCollections, but Evolution API overrides it to max 20

4. getCatalog frequently returns isBusiness: false (unreliable)

The fetchCatalog method catches errors and returns a fallback:

} catch (error) {
  console.log(error);
  return { wuid: jid, name: null, isBusiness: false };
}

This makes getCatalog unreliable β€” it frequently returns empty results even for valid business accounts, while getCollections works consistently.


Proposed Solutions

  1. Increase auto-pagination loops β€” Change countLoops < 4 to a higher value (e.g., countLoops < 20) or make it configurable

  2. Expose cursor in validation schema β€” Add cursor: { type: "string" } to catalogSchema so users can manually paginate

  3. Increase limit default β€” Change data.limit || 10 to data.limit || 50 for better out-of-the-box experience

  4. Remove or increase getCollections item limit β€” Change data.limit <= 20 ? data.limit : 20 to allow higher values (e.g., data.limit || 100)

  5. Add nextPageCursor to getCatalog API response β€” Currently the internal auto-pagination consumes the cursor, but exposing it would allow external pagination


Environment

  • Evolution API version: latest (self-hosted)
  • WhatsApp integration: Baileys
  • Catalog size: 63+ products across 6 collections
  • Business account: Verified and active

Workaround (for anyone facing the same issue)

Currently using getCollections as the primary data source (it returns all products with collection/category info) and skipping getCatalog entirely. However, this still has the 20-item-per-collection limit.

cc: @n8n users who sync WA catalogs β€” this affects any catalog with 50+ products

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions