The API returns categories for most pages for example Ada Lovelace:
https://en.wikipedia.org/w/api.php?format=json&action=query&titles=Ada_Lovelace&prop=categories
But not for the Boxer Rebellion or the second law of thermodynamics:
https://en.wikipedia.org/w/api.php?format=json&action=query&titles=Boxer_Rebellion&prop=categories
https://en.wikipedia.org/w/api.php?format=json&action=query&titles=Second_law_of_thermodynamics&prop=categories
I don't believe these to be the only cases, just the first I've found. Ideally all categories should be returned from all pages.