E-commerce

Categories

Categories provide a flexible tagging system for your store. Unlike collections, a single product can belong to multiple categories simultaneously, making them perfect for faceted filtering, promotional tags, and thematic groupings.

The Tagging Workflow

  1. 1Faceted Filtering: Use categories to build sidebar filters (e.g., "New Arrivals", "Sustainable", "On Sale").
  2. 2Dynamic Labels: Fetch product categories to display badges/tags on your product grid cards.
  3. 3Cross-Linking: Pass multiple category slugs to the /products query to create highly specific results.
  4. 4Rich Discovery: Display category descriptions and cover images on dedicated landing or search pages.

List Categories

Retrieve all available categories. Use this to generate filter sidebars or category-based landing page links.

Request Configuration

Parameters
Live Console
GET/categories
Hit Run to test this endpoint
cURL

Implementation: Fetching Categories

JavaScript
    const getNavigation = async () => {
      const response = await fetch('https://api.electivecommerce.com/v1/categories', {
        method: 'GET',
        headers: {
          'Authorization': 'Bearer pk_live_YOUR_PUBLIC_KEY',
          'Content-Type': 'application/json'
        }
    });   
    const { success, data } = await response.json();
          
    // Array of collection objects including title, slug, description and image_url
    return data;
  };

Get Category Details

Retrieve full metadata for a specific category tag using its unique slug or ID.

:key

Request Configuration

Parameters
Live Console
GET/categories/:key
Hit Run to test this endpoint
cURL

Implementation: Category Metadata

JavaScript
  const getCollectionInfo = async (slug) => {
      const response = await fetch(`https://api.electivecommerce.com/v1/categories/${slug}`, {
        method: 'GET',
        headers: {
          'Authorization': 'Bearer pk_live_YOUR_PUBLIC_KEY',
          'Content-Type': 'application/json'
        }
      });
    
      const { success, data, error } = await response.json();
      
      if (!success) {
        console.error('Collection not found');
        return null;
      }
    return data;
  };