When querying the categories for a page, the list is returned, along with the namespace for each category. Since all categories are in the same namespace, this is unneeded.
Example query: https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&prop=categories&titles=Barack%20Obama&cllimit=max
Current output
{ "batchcomplete": "", "query": { "pages": { "534366": { "pageid": 534366, "ns": 0, "title": "Barack Obama", "categories": [ { "ns": 14, "title": "Category:1961 births" }, { "ns": 14, "title": "Category:20th-century American male writers" }, { "ns": 14, "title": "Category:20th-century American non-fiction writers" }, { "ns": 14, "title": "Category:20th-century Protestants" }, { "ns": 14, "title": "Category:20th-century scholars" }, { "ns": 14, "title": "Category:21st-century American male writers" }, { "ns": 14, "title": "Category:21st-century American non-fiction writers" }, { "ns": 14, "title": "Category:21st-century American politicians" }, { "ns": 14, "title": "Category:21st-century Presidents of the United States" }, { "ns": 14, "title": "Category:21st-century Protestants" }, { "ns": 14, "title": "Category:21st-century scholars" }, { "ns": 14, "title": "Category:AC with 30 elements" }, { "ns": 14, "title": "Category:Activists from Illinois" }, { "ns": 14, "title": "Category:African-American Christians" }, { "ns": 14, "title": "Category:African-American United States presidential candidates" }, { "ns": 14, "title": "Category:African-American United States senators" }, { "ns": 14, "title": "Category:African-American academics" }, { "ns": 14, "title": "Category:African-American educators" }, { "ns": 14, "title": "Category:African-American feminists" }, { "ns": 14, "title": "Category:African-American non-fiction writers" }, { "ns": 14, "title": "Category:African-American state legislators in Illinois" }, { "ns": 14, "title": "Category:All Wikipedia articles written in American English" }, { "ns": 14, "title": "Category:American Nobel laureates" }, { "ns": 14, "title": "Category:American Protestants" }, { "ns": 14, "title": "Category:American civil rights lawyers" }, { "ns": 14, "title": "Category:American community activists" }, { "ns": 14, "title": "Category:American feminist writers" }, { "ns": 14, "title": "Category:American gun control advocates" }, { "ns": 14, "title": "Category:American legal scholars" }, { "ns": 14, "title": "Category:American male non-fiction writers" }, { "ns": 14, "title": "Category:American memoirists" }, { "ns": 14, "title": "Category:American people of English descent" }, { "ns": 14, "title": "Category:American people of French descent" }, { "ns": 14, "title": "Category:American people of German descent" }, { "ns": 14, "title": "Category:American people of Irish descent" }, { "ns": 14, "title": "Category:American people of Kenyan descent" }, { "ns": 14, "title": "Category:American people of Luo descent" }, { "ns": 14, "title": "Category:American people of Scottish descent" }, { "ns": 14, "title": "Category:American people of Swiss descent" }, { "ns": 14, "title": "Category:American people of Welsh descent" }, { "ns": 14, "title": "Category:American political writers" }, { "ns": 14, "title": "Category:American politicians of Luo descent" }, { "ns": 14, "title": "Category:Articles containing video clips" }, { "ns": 14, "title": "Category:Articles with Curlie links" }, { "ns": 14, "title": "Category:Articles with Encyclop\u00e6dia Britannica links" }, { "ns": 14, "title": "Category:Articles with Internet Archive links" }, { "ns": 14, "title": "Category:Articles with LibriVox links" }, { "ns": 14, "title": "Category:Articles with Project Gutenberg links" }, { "ns": 14, "title": "Category:Articles with hAudio microformats" }, { "ns": 14, "title": "Category:Articles with short description" }, { "ns": 14, "title": "Category:Barack Obama" }, { "ns": 14, "title": "Category:CS1 Indonesian-language sources (id)" }, { "ns": 14, "title": "Category:CS1 errors: missing periodical" }, { "ns": 14, "title": "Category:Candidates in the 2008 United States presidential election" }, { "ns": 14, "title": "Category:Candidates in the 2012 United States presidential election" }, { "ns": 14, "title": "Category:Columbia University alumni" }, { "ns": 14, "title": "Category:Democratic Party (United States) presidential nominees" }, { "ns": 14, "title": "Category:Democratic Party Presidents of the United States" }, { "ns": 14, "title": "Category:Democratic Party United States senators" }, { "ns": 14, "title": "Category:Featured articles" }, { "ns": 14, "title": "Category:Grammy Award winners" }, { "ns": 14, "title": "Category:Harvard Law School alumni" }, { "ns": 14, "title": "Category:HuffPost writers and columnists" }, { "ns": 14, "title": "Category:Illinois Democrats" }, { "ns": 14, "title": "Category:Illinois lawyers" }, { "ns": 14, "title": "Category:Illinois state senators" }, { "ns": 14, "title": "Category:Living people" }, { "ns": 14, "title": "Category:Male feminists" }, { "ns": 14, "title": "Category:Members of the American Philosophical Society" }, { "ns": 14, "title": "Category:Nobel Peace Prize laureates" }, { "ns": 14, "title": "Category:Obama family" }, { "ns": 14, "title": "Category:Occidental College alumni" }, { "ns": 14, "title": "Category:Official website different in Wikidata and Wikipedia" }, { "ns": 14, "title": "Category:Pages containing links to subscription-only content" }, { "ns": 14, "title": "Category:Pages including recorded pronunciations (English)" }, { "ns": 14, "title": "Category:Pages with editnotices" }, { "ns": 14, "title": "Category:Politicians from Chicago" }, { "ns": 14, "title": "Category:Politicians from Honolulu" }, { "ns": 14, "title": "Category:Presidents of the United States" }, { "ns": 14, "title": "Category:Proponents of Christian feminism" }, { "ns": 14, "title": "Category:Punahou School alumni" }, { "ns": 14, "title": "Category:United States senators from Illinois" }, { "ns": 14, "title": "Category:University of Chicago Law School faculty" }, { "ns": 14, "title": "Category:Use American English from August 2018" }, { "ns": 14, "title": "Category:Use mdy dates from March 2019" }, { "ns": 14, "title": "Category:Wikipedia articles with BIBSYS identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with BNC identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with BNE identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with BNF identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with CINII identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with GND identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with ISNI identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with LCCN identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with LNB identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with MusicBrainz identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NCL identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NDL identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NKC identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NLA identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NLI identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NLP identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NLR identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NSK identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with NTA identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with RERO identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with RKDartists identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with RSL identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with SBN identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with SELIBR identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with SNAC-ID identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with SUDOC identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with Trove identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with ULAN identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with USCongress identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with VIAF identifiers" }, { "ns": 14, "title": "Category:Wikipedia articles with WorldCat-VIAF identifiers" }, { "ns": 14, "title": "Category:Wikipedia indefinitely move-protected pages" }, { "ns": 14, "title": "Category:Wikipedia indefinitely semi-protected pages" }, { "ns": 14, "title": "Category:Writers from Chicago" } ] } } }, "limits": { "categories": 500 } }
Ideal output
{ "batchcomplete": "", "query": { "pages": { "534366": { "pageid": 534366, "ns": 0, "title": "Barack Obama", "categories": [ "Category:1961 births", "Category:20th-century American male writers", "Category:20th-century American non-fiction writers", "Category:20th-century Protestants", "Category:20th-century scholars", "Category:21st-century American male writers", "Category:21st-century American non-fiction writers", "Category:21st-century American politicians", "Category:21st-century Presidents of the United States", "Category:21st-century Protestants", "Category:21st-century scholars", "Category:AC with 30 elements", "Category:Activists from Illinois", "Category:African-American Christians", "Category:African-American United States presidential candidates", "Category:African-American United States senators", "Category:African-American academics", "Category:African-American educators", "Category:African-American feminists", "Category:African-American non-fiction writers", "Category:African-American state legislators in Illinois", "Category:All Wikipedia articles written in American English", "Category:American Nobel laureates", "Category:American Protestants", "Category:American civil rights lawyers", "Category:American community activists", "Category:American feminist writers", "Category:American gun control advocates", "Category:American legal scholars", "Category:American male non-fiction writers", "Category:American memoirists", "Category:American people of English descent", "Category:American people of French descent", "Category:American people of German descent", "Category:American people of Irish descent", "Category:American people of Kenyan descent", "Category:American people of Luo descent", "Category:American people of Scottish descent", "Category:American people of Swiss descent", "Category:American people of Welsh descent", "Category:American political writers", "Category:American politicians of Luo descent", "Category:Articles containing video clips", "Category:Articles with Curlie links", "Category:Articles with Encyclop\u00e6dia Britannica links", "Category:Articles with Internet Archive links", "Category:Articles with LibriVox links", "Category:Articles with Project Gutenberg links", "Category:Articles with hAudio microformats", "Category:Articles with short description", "Category:Barack Obama", "Category:CS1 Indonesian-language sources (id)", "Category:CS1 errors: missing periodical", "Category:Candidates in the 2008 United States presidential election", "Category:Candidates in the 2012 United States presidential election", "Category:Columbia University alumni", "Category:Democratic Party (United States) presidential nominees", "Category:Democratic Party Presidents of the United States", "Category:Democratic Party United States senators", "Category:Featured articles", "Category:Grammy Award winners", "Category:Harvard Law School alumni", "Category:HuffPost writers and columnists", "Category:Illinois Democrats", "Category:Illinois lawyers", "Category:Illinois state senators", "Category:Living people", "Category:Male feminists", "Category:Members of the American Philosophical Society", "Category:Nobel Peace Prize laureates", "Category:Obama family", "Category:Occidental College alumni", "Category:Official website different in Wikidata and Wikipedia", "Category:Pages containing links to subscription-only content", "Category:Pages including recorded pronunciations (English)", "Category:Pages with editnotices", "Category:Politicians from Chicago", "Category:Politicians from Honolulu", "Category:Presidents of the United States", "Category:Proponents of Christian feminism", "Category:Punahou School alumni", "Category:United States senators from Illinois", "Category:University of Chicago Law School faculty", "Category:Use American English from August 2018", "Category:Use mdy dates from March 2019", "Category:Wikipedia articles with BIBSYS identifiers", "Category:Wikipedia articles with BNC identifiers", "Category:Wikipedia articles with BNE identifiers", "Category:Wikipedia articles with BNF identifiers", "Category:Wikipedia articles with CINII identifiers", "Category:Wikipedia articles with GND identifiers", "Category:Wikipedia articles with ISNI identifiers", "Category:Wikipedia articles with LCCN identifiers", "Category:Wikipedia articles with LNB identifiers", "Category:Wikipedia articles with MusicBrainz identifiers", "Category:Wikipedia articles with NCL identifiers", "Category:Wikipedia articles with NDL identifiers", "Category:Wikipedia articles with NKC identifiers", "Category:Wikipedia articles with NLA identifiers", "Category:Wikipedia articles with NLI identifiers", "Category:Wikipedia articles with NLP identifiers", "Category:Wikipedia articles with NLR identifiers", "Category:Wikipedia articles with NSK identifiers", "Category:Wikipedia articles with NTA identifiers", "Category:Wikipedia articles with RERO identifiers", "Category:Wikipedia articles with RKDartists identifiers", "Category:Wikipedia articles with RSL identifiers", "Category:Wikipedia articles with SBN identifiers", "Category:Wikipedia articles with SELIBR identifiers", "Category:Wikipedia articles with SNAC-ID identifiers", "Category:Wikipedia articles with SUDOC identifiers", "Category:Wikipedia articles with Trove identifiers", "Category:Wikipedia articles with ULAN identifiers", "Category:Wikipedia articles with USCongress identifiers", "Category:Wikipedia articles with VIAF identifiers", "Category:Wikipedia articles with WorldCat-VIAF identifiers", "Category:Wikipedia indefinitely move-protected pages", "Category:Wikipedia indefinitely semi-protected pages", "Category:Writers from Chicago" ] } } }, "limits": { "categories": 500 } }