Here is a simple snippet that let you get all categories from a vocabulary. A vocabulary is always pinned to a group (either a simple group or to the global group of a company).

// Get vocabulary "" (from myGroup)
AssetVocabulary vocabulary = AssetVocabularyLocalServiceUtil.getGroupVocabulary(myGroup.getGroupId(), "");

// Get all categories from vocabulary ""
List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getVocabularyCategories(vocabulary.getVocabularyId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

NB: you can use method “getVocabularyRootCategories” to get the level-0 categories of your vocabulary.