I’ll continue my previous post about Consuming WordPress JSON API and Tags by showing you how to Grab the Categories and their related Posts or Products from the JSON API of a WordPress Web Site.
Load Post Categories
The Post Categories list endpoint is located under the address https://<wp>/wp-json/wp/v2/categories[?parent=<id>]. It has the following JSON Model:

The [?parent=<id>] part of the URL is optional. If it is present you’ll get a filtered result – only the children of some parent category or all categories otherwise. The fields of the category data model are:
- id : Integer
- name: String – populated in the WordPress Admin Interface
- description: String – populated in the WordPress Admin Interface
- slug: String – URL friendly String of the category (again open for modification by the admin).
- count: the number of products that have the category.
- parent: Integer – the ID of the parent category or 0(zero) if it does not have a parent
To Filter Posts by Category, you must hit the following URL: https://<wp>/wp-json/wp/v2/posts?categories=<id>.
To demonstrate the Blog Posts Categories I’ve created a Flutter Web Application that loads them from this website: https://programtom.com/dev_examples/wp_categories/posts/. More complete display of information will be extended with the inclusion of other WordPress Data Models.
Load Product Categories
The Product Categories are located on the following sub-address: https://<wp>/wp-json/wc/store/products/categories

- id : Integer
- name: String – populated in the WordPress Admin Interface
- description: String – populated in the WordPress Admin Interface
- slug: String – URL friendly String of the category (again open for modification by the admin).
- count: the number of products that have the category.
- parent: Integer – the ID of the parent category or 0(zero) if it does not have a parent
- review_count: Integer – products are also able to have reviews by other users
- permalink: String – the URL of slug Product Category – formed by concatenating the slug with “https://<wp>/product-category/<slug>/<slug1>”. If there is a parent the slug is the slug of the parent and the slug1 is the current. Otherwise the slug1 is missing. All this monkey business is because of Search Engine Optimization.
- It has an Image Sub-Object with the following properties as (probably) most important
- src – the source of the original (best) quality
- thumbnail – a less good version of the image, but appropriate in many places where the best quality is not required
To Filter Products by certain Category you could hit the following URL: https://<wp>/wp-json/wc/store/products?category=<id>
To demonstrate the Blog Posts Categories I’ve created a Flutter Web Application that loads the categories from this website: https://programtom.com/dev_examples/wp_categories/products.