Shields: Provide API to get badge state as a JSON result

Created on 31 Mar 2020  Â·  6Comments  Â·  Source: badges/shields

:clipboard: Description

You already have an endpoint for JSON-to-badge conversion, but when one wants to display the badge data you already have (and implemented the API).

use case: If one, however, wants to just get the data from one of your implemented APIs, to display the data in a different way than a badge (a table e.g.), this is not easily possible.

workaround: One could of course request the SVG and extract the text from the SVG, however that is cumbersome.

reasoning: It is easier to implement and query one API (of yours) than it is to check each single API doc you also just use and implement the service by oneself.
So you could be an easy "proxy" here, that also very conveniently does caching and provides simple results (considering some third-party APIs return much more data than needed).

solution: IMHO just an endpoint like https://data.shields.io/… that just returns the original data would be nice IMHO.

question

All 6 comments

You can add a .json extension on any of our badges to get that representation of the badge data

For example: https://img.shields.io/appveyor/build/gruntjs/grunt.json

Is that what you're asking for?

Yes it is! (I did not saw this being documented anywhere. :smiley:)

Okay wait another question. I have this badge URL:
https://img.shields.io/mozilla-observatory/grade/bin.snopyta.org.svg

There it does not work, adding it anywhere in the middle it fails, and if I do https://img.shields.io/mozilla-observatory/grade/bin.snopyta.org.svg.json it apparently tries to use the .json as the domain address. :thinking:

Edit: Stupid me. It's obviously https://img.shields.io/mozilla-observatory/grade/bin.snopyta.org.json

@rugk There is a little note at the bottom of the website. It could be expanded to make it clearer what the JSON format is. A contribution would be welcome.

Though we also want people to use this feature sparingly, such as to render badges using their own templates. It's better in most cases to hit the underlying APIs yourself.

Though we also want people to use this feature sparingly, such as to render badges using their own templates.

Agreed. The Shields.io service is intended to provide badges to folks, and isn't readily equipped to be an aggregate API/middle tier to provide data for the myriad services we provide badges for (especially with the limitations of our current production runtime0

Feel free to open a PR for the docs if you'd like!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niccokunzmann picture niccokunzmann  Â·  3Comments

lukeeey picture lukeeey  Â·  3Comments

salaros picture salaros  Â·  3Comments

PyvesB picture PyvesB  Â·  3Comments

rominf picture rominf  Â·  3Comments