To get all categories and subcategories from the API, you need to make a request to /site.json. If you don’t mind looking at PHP/WordPress code, there’s an example API request to get all categories here: wp-discourse/lib/plugin-utilities.php at main · discourse/wp-discourse · GitHub.