1. Category Index
Endpoints
- /categories?store={store_id}&parent={category_id}&query={search_query}&country-code={country_code}
Method: GET
Requires Authentication: NO
Parameters
-
store
The store ID to filter
-
query
The query to filter
-
parent
The category ID that needs to be the parent of the categories in the response, if the front does not specify a parent, the API will return the categories that don´t have parents
-
country-code
Comments
Important!
The response structure will vary depending on the parameters.
If the front doesn´t specify a store, the api will return a pagination.
If the front does specify a store, the api will return the data without a pagination.
When the store is specified, the "children_count" may not be accurate.
For example, it may say that the category has 3 children, but when we ask for those categories, we might get less of them.
This is because those 3 categories might not have products in the store (but they do exists) so the api directly won´t show them.
In any case.
In order to know if the front needs to ask for the products in the category we need to see if the "children_count" is equal to zero.
If it is equal to zero, then the category is a "leaf" category, and we can ask for the products.
If it is anything different than zero, then the category is a parent category with subcategories and we should get those child categories.
Responses
-
Success (without specifying store)
Status code: 200
-
Success (specifying store)
Status code: 200