2

I see we can fetch tags via the API, which works fine but, sadly, there doesn't seem to be a way to get the count of all possible tags.

Currently the Stack Overflow Tags page shows 36 tags per page with pagination up to page 1426, which means there are up to 51336 tags.

Does the API have any such feature?

0

1 Answer 1

2

The question was not originally clear if you wanted tags or badges, but the answer is the same...

To just get totals, use the total filter.
For example, for badges: /badges?site=stackoverflow&filter=total, which currently returns:

{"total":6363}

For tags: /tags?site=stackoverflow&filter=total, which currently returns:

{"total":48667}

WARNING:

In practice, the total filter is dangerous, because it masks errors, warnings and backoff intervals.
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 backoff warnings.

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .