How to get Categories using Catalog V3 API

I’m having trouble with
fetching Category related info in Catalog V3 API.

What I’m trying to do
I’m working on Catalog V3 API and I’m using V3 API to fetch my customers Products and Category. I’m using “https://www.wixapis.com/stores/v3/products/query” API to fetch products from store. BUT I’m facing issue regarding category information.

It can be easily fetched using “https://www.wixapis.com/stores/v1/collections/query” in V1 API but not finding any API in V3.

Please help me out.

But on using V1’s /collections/query API I’m getting this error :

Try Following Code, I don’t have the V3 right now so don’t know if it will work, May you test and let me know if it works though. I will need it for an apps. I have added a log, it should show the products in the dev console in website preview if the code works.

import { productsV3 } from '@wix/stores';

async function fetchAllProducts() {
  try {
    const { items } = await productsV3.queryProducts().find();
    console.log(items);
    return items;
  } catch (error) {
    console.error('Error fetching products:', error);
    throw error;
  }
}

fetchAllProducts();

FYI, I am using the Wix SDK instead. Install the @wix/stores package first.

This snippet helps in fetching Products and I’m able to fetch products from the API also. The main issue arise for Categories fetching. I’m not able to fetch categories.

I see, Sorry about that. I can see a fetchAllProductsCategory function in the V3 SDK, try following code.

import { productsV3 } from '@wix/stores';

async function fetchAllProductsCategory() {
  try {
    const response = await productsV3.getAllProductsCategory();
    console.log('Category ID:', response.categoryId);
    console.log('Tree Reference:', response.treeReference);
    return response;
  } catch (error) {
    console.error('Error fetching product categories:', error);
    throw error;
  }
}

fetchAllProductsCategory();

I am not sure to to fetch the names though, may be use the Category collection to match the IDs with the Item title.

I already tried this API, but it only returns the ‘ALL Products’ category detail. As the name ‘fetchAllProductsCategory’ also suggests.

I want to fetch all the other category users have created in their V3 store.