Lab - Brands and Categories
Lab - Brands and Categories
This lab activity will give you a chance to practice working with brands and categories via the Catalog API. Each step will walk you through how to use all of the endpoints covered in the previous lesson.
Prerequisites:
- BigCommerce store (sandbox or live)
- Basic knowledge of APIs
- REST client (Postman)
- Completion of Catalog API labs 1 thru 3
In this lab, you will:
- Create a brand
- Assign a product to a brand
- GET brands
- Create a category
- Update category by id
- Assign a product to different categories
- GET categories
- GET category tree
The concept of category trees facilitates multi-storefront setups by allowing each storefront to have its own category hierarchy. Even in a single storefront context, however, it is still appropriate to use these API endpoints for all category operations. Where there is only a single storefront, all categories will exist in category tree ID 1.
Create a Brand
- Copy and paste the request below into Postman
- Copy and paste the code below into the Body section of Postman
- Select POST next to the request url
- Click the Send button
- Observe response and the brand created in the store
- Copy the brand ID for next steps
Assign a Product to a Brand
- Copy and paste the request below into Postman
- Enter the ID for the product created in the previous lab for
product_idin the Params tab - Copy and paste the code below into the Body section of Postman
- Replace
{id}with the ID of the brand created in previous step - Select PUT next to the request url
- Click the Send button
- Observe response and product assigned to new brand
GET Brands
- Copy and paste the request below into Postman
- Select GET next to the request url (if not already selected)
- Click the Send button
- Observe response
Create a Category
- Copy and paste the request below into Postman
- Copy and paste the code below into the Body section of Postman
- Select POST next to the request url
- Click the Send button
- Observe response and category created in store
- Copy category ID for next steps
Update a Category
- Copy and paste the request below into Postman
- Copy and paste the code below into the Body section of Postman
- Replace
{id}with the ID of the category created in the previous steps - Select PUT next to the request url
- Click the Send button
- Observe response
Assign a Product to a Category
- Copy and paste the request below into Postman
- Enter the ID for the product used in previous steps for
product_idin the Params tab - Copy and paste the code below into the Body section of Postman
- Replace
{id}with the ID of the category created in previous step - Select PUT next to the request url
- Click the Send button
- Observe response and product assigned to new category
To add a product to a category instead of replacing its category, follow the steps above and copy the existing array over into your request. The request will look like this:
GET Category Tree
- Copy and paste the request below into Postman
- Select GET next to the request url (if not already selected)
- Click the Send button
- Observe response