The question was not originally clear if you wanted tags or badges, but the answer is the same...
To just get totals, use the
For example, for badges: /badges?site=stackoverflow&filter=total, which currently returns:
For tags: /tags?site=stackoverflow&filter=total, which currently returns:
In practice, the
total filter is dangerous, because it masks errors, warnings and
So, in practice use
!w-*Ytm8YGWVl9..xoC instead of
total, per: My filter is not returning any results. How to create a minimal filter?.
If you want both the badges/tags and the total, you can set a custom filter, or just count the members of the
items array as you page through them. The latter option is less expensive in the API and thus less likely to get you
Note that you can set the pagesize up to 100. See the doc page for tags, for example.
IMPORTANT: The Tags page also shows synonyms and also a great many tags that have zero questions.
The API /tags route , however, returns neither of these, as best as I can tell‡. (3 or 4 very recently orphaned tags being the exception). So the totals will not match up.
‡EG, currently Stack Apps only has 7 synonyms. Confirmed that none of those show in the /tags route, but all show on the Tags pages. Likewise, the only zero count tag in the API is currently the featured tag, which is moderator only.