# Shields.io unable to retrieve Discourse statistics API

**URL:** https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574
**Category:** Support
**Created:** [September 14, 2019, 1:25pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574 "2019-09-14T13:25:54Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![haikalpribadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haikalpribadi/32/112126_2.png) [@haikalpribadi](https://meta.discourse.org/u/haikalpribadi)
#### Post date: [September 14, 2019, 1:25pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/1 "2019-09-14T13:25:54Z")

</div>

Hi everyone,

We’ve had a Discourse shield on our repository for a while now, and it recently stopped working.

If you go to [404: badge not found](https://shields.io/category/chat) and select any Discourse shield, you can enter your discourse domain address and it will show you the shield with the correct statistics. You can try this with [meta.discourse.org](http://meta.discourse.org).

However, when we enter our discourse host address ([https://discuss.grakn.ai](https://discuss.grakn.ai)), for any statistics and for both http/https, it always returns “invalid”.

[![Discussion Forum](https://global.discourse-cdn.com/meta/original/3X/5/e/5ed9e8058dc6f612ad909d989e1277eb91e09e71.svg)](https://discuss.grakn.ai)

When a host is not found, [Shields.io](http://Shields.io) would return “inaccessible”. Thus we assume “invalid” means it’s accessible but there are access rights issues or invalid responses.

Is it possible that a recent update/upgrade broke something on Discourse statistics API that [Shields.io](http://Shields.io) uses?

Thank you so much!

---

<div class="post-metadata">

### Author: ![marianord](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marianord/32/90502_2.png) [@marianord](https://meta.discourse.org/u/marianord)
#### Post date: [September 15, 2019, 3:00am UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/2 "2019-09-15T03:00:43Z")

</div>

It’s working for me in my site, maybe you’re not setting correctly the protocol? Or the Grakn Discourse has any kind on modification that breaks that endpoint.

![imagen](https://global.discourse-cdn.com/meta/original/3X/b/4/b41e776b146502aa2c8f8414ce2ff12b11c42829.png)

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [September 15, 2019, 10:35am UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/3 "2019-09-15T10:35:22Z")

</div>

You might want to ask [Shields.io](http://Shields.io) about that problem. It works with all other sites I tested, so this isn’t our bug.

---

<div class="post-metadata">

### Author: ![haikalpribadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haikalpribadi/32/112126_2.png) [@haikalpribadi](https://meta.discourse.org/u/haikalpribadi)
#### Post date: [September 15, 2019, 7:20pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/4 "2019-09-15T19:20:54Z")

</div>

@marianord that’s exactly my question: where are the “protocols” you’re mentioning? How can they be configured? I’ve not changed any settings.

@gerhard given that [shields.io](http://shields.io) is working for other Discourse sites, it does not seem likely to be an issue on their side. Unless they’re re not reading the output from our site statistics properly - but how can we find out about this? What is the endpoint from Discourse that is used to query the statistics? Perhaps we should start there?

---

<div class="post-metadata">

### Author: ![marianord](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marianord/32/90502_2.png) [@marianord](https://meta.discourse.org/u/marianord)
#### Post date: [September 15, 2019, 7:27pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/5 "2019-09-15T19:27:23Z")

</div>

I’m mentioning `http` vs `https`.

---

<div class="post-metadata">

### Author: ![max\_grakn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/max_grakn/32/156681_2.png) [@max\_grakn](https://meta.discourse.org/u/max_grakn)
#### Post date: [September 19, 2019, 11:05am UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/6 "2019-09-19T11:05:56Z")

</div>

This happened because our Discourse installation blocked [Shields.io](http://Shields.io)’s user agent (`Shields.io`). This setting is named _whitelisted crawler user agents_ and can be edited at  
\<discourse\_server\>/admin/site\_settings/category/all\_results?filter=crawler

---

<div class="post-metadata">

### Author: ![haikalpribadi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haikalpribadi/32/112126_2.png) [@haikalpribadi](https://meta.discourse.org/u/haikalpribadi)
#### Post date: [September 19, 2019, 11:18am UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/7 "2019-09-19T11:18:05Z")

</div>

Interesting! Thank you @max_grakn! We did add Googlebot to the whitelist recently, I think that may be the cause.

@codinghorror are we meant to use Blacklist and Whitelist at the same time? As in, if you add things to whitelist, does that mean everything else is blacklisted (which therefore make the blacklist redundant)?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 19, 2019, 12:41pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/8 "2019-09-19T12:41:39Z")

</div>

No, the crawler whitelist is very dangerous, and should only be used carefully per the help text.

> User agents of web crawlers that should be allowed to access the site. WARNING! SETTING THIS WILL DISALLOW ALL CRAWLERS NOT LISTED HERE!

---

<div class="post-metadata">

### Author: ![barto\_95](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/barto_95/32/199996_2.png) [@barto\_95](https://meta.discourse.org/u/barto_95)
#### Post date: [November 13, 2020, 10:16am UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/10 "2020-11-13T10:16:19Z")

</div>

Hi, I have the same problem when a test I received invalid data… do you have idea ?

> **[Home Assistant Communauté Francophone](https://forum.hacf.fr)**
>
> Communauté Francophone Home Assistant

It’s OK now, it’s necessary to activated anonymous statistic in :

Admin → setting → other → share anonymized statistics = Enabled

and now it’s ok for [shields.io](http://shields.io)

---

<div class="post-metadata">

### Author: ![spdegabrielle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spdegabrielle/32/190784_2.png) [@spdegabrielle](https://meta.discourse.org/u/spdegabrielle)
#### Post date: [November 15, 2023, 6:22pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/11 "2023-11-15T18:22:58Z")

</div>

I have the same problem, but share anonymous statistics is already enabled  
😢

```plaintext
[![Racket Discourse](upload://6fa5jbSn04vRLXdubAYmFJt5emf.svg)]

```

[![Racket Discourse](https://global.discourse-cdn.com/meta/original/4X/2/b/c/2bc3d35a61a77c980c0eb687437c2b39fb31ede3.svg)]

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [November 15, 2023, 7:41pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/12 "2023-11-15T19:41:54Z")

</div>

Related to:

[https://github.com/discourse/discourse/pull/23933](https://github.com/discourse/discourse/pull/23933)

It’s because a few fields have been renamed in their plural form.

`topic_count` → `topics_count`  
`post_count` → `posts_count`  
`user_count` → `users_count`  
`like_count` → `likes_count`

Someone will need to modify the code here to fallback to the plural form:

> <https://github.com/badges/shields/blob/master/services/discourse/discourse.service.js>

---

<div class="post-metadata">

### Author: ![spdegabrielle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spdegabrielle/32/190784_2.png) [@spdegabrielle](https://meta.discourse.org/u/spdegabrielle)
#### Post date: [November 20, 2023, 3:52pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/13 "2023-11-20T15:52:44Z")

</div>

This is still broken - is it working for anyone else ?

![Racket Discourse](https://global.discourse-cdn.com/meta/original/4X/3/2/3/323e16d850ca390428dee87d32dc5ad88c66c04f.svg)

```plaintext
![Racket Discourse](upload://7asTK98zfWLXRebm11uEN3KPM5N.svg)

```

---

<div class="post-metadata">

### Author: ![BryanV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryanv/32/226479_2.png) [@BryanV](https://meta.discourse.org/u/BryanV)
#### Post date: [December 6, 2023, 5:35pm UTC](https://meta.discourse.org/t/shields-io-unable-to-retrieve-discourse-statistics-api/128574/14 "2023-12-06T17:35:34Z")

</div>

There was a PR opened a few days ago:

[https://github.com/badges/shields/pull/9778](https://github.com/badges/shields/pull/9778)

But naturally this change places a burden on `shields.io` to support _both_ versions (in perpetuity, I guess) since there is no guarantee that any given Discourse instance has updated or not, so it is not so simple as changing to plurals.
