Skip to content
On this page

Categories

Categories is the main part of the headless API. By categories you will be able no navigate through the store and find products.

Best practice

  1. Call category route and present category description, filters etc
  2. Call category products and present products
  3. Use filters and sort based on user input

Category

GET: /headless_api/categories/{category_slug}

Returns an object with category data and filter tags

{
    "data": {
        "id": 1,
        "parent_id": null,
        "breadcrumbs": [
            {
                "title": "Home",
                "slug": ""
            },
            {
                "title": "Clothes",
                "slug": "clothes"
            }
        ],
        "name": "Clothes",
        "slug": "clothes",
        "description": "Category description",
        "image": null,
        "meta_title": "Meta title",
        "meta_description": "Meta description",
        "children": [],
        "filter_tags": [
            {
                "type": "COLOR", // Available COLOR, CHECKBOX
                "title": "Color",
                "tags": [
                    {
                        "tag": "color_red",
                        "group_title": "Color",
                        "attribute_title": "Red"
                    }
                ]
            }
        ],
        "template_components": [
            // Array of template components
        ]
    }
} 

Category products

Returns paginated products related to category

GET: /headless_api/categories/{category_slug}/products

Filters

GET: ?page=1&sort=price_low&filters=color_red

GETTypeValues
pageint-
sortstringprice_low, price_high, published, name_z, name_a, popular
filtersstringfilter_tags comma separated

Result

{
    "data": [ // Products
        {
            "name": "Black t-shirt",
            "primary_sku": "810021-555-00",
            "slug": "black-t-shirt",
            "is_new": false, // Boolean
            "image": {
                "id": 6188,
                "sort_order": 0,
                "name": "9G0ueaMwZrtRwf61633359232",
                "title": "Black t-shirt",
                "alt_tag": "",
                "path_xs": "https://d3dnwnveix5428.cloudfront.net/image_hash",
                "path_small": "https://d3dnwnveix5428.cloudfront.net/image_hash",
                "path_medium": "https://d3dnwnveix5428.cloudfront.net/image_hash",
                "path_large": "https://d3dnwnveix5428.cloudfront.net/image_hash",
                "path_xl": "https://d3dnwnveix5428.cloudfront.net/image_hash"
            },
            "primary_price": {
                "currency": {
                    "name": "Svenska kronor",
                    "iso": "SEK",
                    "format": "{value} kr",
                    "decimal_separator": ",",
                    "thousand_separator": " "
                },
                "tier": 1,
                "price": 223.2,
                "price_inc_vat": 279,
                "formatted_price": "279 kr",
                "price_in_cents": 22320,
                "price_in_cents_inc_vat": 27900,
                "compare_price": 0,
                "compare_price_inc_vat": 0,
                "formatted_compare_price": "0 kr"
            },
            "stock": 4,
            "brand": null,
            "meta_description": ""
        }
    ],
    "links": {
        "first": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=1",
        "last": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=3",
        "prev": null,
        "next": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=2"
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 3,
        "links": [
            {
                "url": null,
                "label": "« Föregående",
                "active": false
            },
            {
                "url": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=2",
                "label": "2",
                "active": false
            },
            {
                "url": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=3",
                "label": "3",
                "active": false
            },
            {
                "url": "https://yourdomain.com/headless_api/categories/{category_slug}/products?page=2",
                "label": "Nästa »",
                "active": false
            }
        ],
        "path": "https://yourdomain.com/headless_api/categories/{category_slug}/products",
        "per_page": 48,
        "to": 48,
        "total": 114
    }
}