badges / gh-badges

Go to badges/shields. Especially if you don't know why. (This repo is old.)
http://img.shields.io/
Creative Commons Zero v1.0 Universal
86 stars 29 forks source link

Work with existing services #16

Closed espadrine closed 10 years ago

espadrine commented 10 years ago

When possible (when an API is available), we should have a way to provide a bridge to existing services.

eg, gh-badges.herokuapp.com/travis/joyent/node.svg.

This issue is to discuss which APIs we can access, and what is the most efficient way to do so.

espadrine commented 10 years ago

Let's start with Travis-CI. It seems the fastest way to get to the information is through:

https://api.travis-ci.org/repositories/<USER/REPO>.json

eg, https://api.travis-ci.org/repositories/joyent/node.json.

espadrine commented 10 years ago

We can also do Coveralls with https://coveralls.io/repos/<USER/REPO>/badge.png?branch=master. It's a bit trickier, because it redirects you to an Amazon S3 instance image, but the image URL contains the information we need: https://s3.amazonaws.com/assets.coveralls.io/badges/coveralls_73.png.

espadrine commented 10 years ago

Gittip is probably the nicest to play with: https://www.gittip.com/JSFiddle/public.json.

espadrine commented 10 years ago

I'll keep this issue around. Add suggestions here!

espadrine commented 10 years ago

There's no obvious way to have built-in support for gemnasium (#19), short of parsing the HTML.

mathiasbynens commented 10 years ago

Yeah, probably not worth it for Gemnasium. Let’s just hope they’re willing to implement the SVG badges themselves :)

espadrine commented 10 years ago

Packagist has a smooth albeit verbose JSON interface: https://packagist.org/packages/<USER/REPO>.json.

espadrine commented 10 years ago

Coming from Packagist, NPM's interface was rather bothersome. On one side, we have the rather verbose but elegant still NPM registry: https://registry.npmjs.org/<REPO>/latest which includes the NPM version and the dependencies'.

However, if you want to see the download count, you have to parse this: http://isaacs.iriscouch.com/downloads/_design/app/_view/pkg?group_level=2&start_key=[%22<REPO>%22]&end_key=[%22<REPO>%22,{}]. It's also the only one to forbid https.

The resulting JSON gives a list of daily downloads, which have to be added up to compute monthly downloads.

espadrine commented 10 years ago

Ruby gems are the nicest so far: https://rubygems.org/api/v1/gems/<REPO>.json

espadrine commented 10 years ago

Code climate has a Content-Disposition HTTP header with the score in the file name. See eg curl -I https://codeclimate.com/github/kabisaict/flow.png:

Content-Disposition: inline; filename="code_climate-4-0.png"
espadrine commented 10 years ago

Happy days! Gemnasium follows the same pattern. Its Content-Disposition looks like this, eg, https://gemnasium.com/gemnasium/gemnasium-gem.png:

Content-Disposition: inline; filename="dev-yellow.png"
rasky commented 10 years ago

You could add support for PyPI info too, see: https://github.com/badges/pypipins/blob/master/pins/pins.py

It's a simple JSON.

espadrine commented 10 years ago

@rasky Great idea! Thanks for linking to code!

So, PyPI has dethroned Gems as the nicest API: https://pypi.python.org/pypi/<EGG>/json.

rasky commented 10 years ago

Thanks!

You put only downloads, what about other fields? pypins handle also latest, egg/wheel and license.

Actually, "license" is not very useful, since you don't change license often, so it can be a static badge.

espadrine commented 10 years ago

I do it little by little. Right now, downloads and version (latest?). I'm not sure what Egg and Wheel are, so I'll need to learn.

nathany commented 10 years ago

Wheel is a new binary format (esp. useful for C extensions). Eggs are on the way out but still fairly prevalent? (afaik)

espadrine commented 10 years ago

Is this exclusive? @rasky @kura Would a badge like [ format | wheel ] vs. [ format | egg ] (vs. [ format | none ]) work?

Also, what should the color be?

rasky commented 10 years ago

You can copy what they do here: https://pypip.in

espadrine commented 10 years ago

Sure, but I'm thinking in terms of which badge would be most interesting to display. [ wheel | yes ] isn't immediately obvious, and we may be able to improve that. What do you think?

espadrine commented 10 years ago

For the sake of continuity, here's how Hackage does their API: https://hackage.haskell.org/package/<REPO>/<REPO>.cabal. Of course they have their own format! But acf16d61e77ac687ca96ddda9dd324fdf278d033 made it work anyway.

kura commented 10 years ago

Sorry, what have I missed RE PyPI?

On the format question by @espadrine, having format | egg/wheel could work, I could make egg = red, wheel = green and none = red, might make more sense to do this now and have wheel being the first thing we look for.

espadrine commented 10 years ago

@kura That sounds pretty good! Are you going to implement that in pypip? shields?

(Otherwise I'll do the shields one today…)

kura commented 10 years ago

I'll put it in pypipins seeing as it's kind of the PyPI shield interface.

kura commented 10 years ago

@espadrine done - https://pypip.in/format.html

espadrine commented 10 years ago

Excellent!

espadrine commented 10 years ago

Cocoapods has a JSON API: http://search.cocoapods.org/api/v1/pod/<POD NAME>.json. eg.

Their API description here.

espadrine commented 10 years ago

GitHub has a JSON API too: https://api.github.com/repos/<USER/REPO>/tags. eg.

Their API description here.