badges / shields

Concise, consistent, and legible badges in SVG and raster format
https://shields.io
Creative Commons Zero v1.0 Universal
23.67k stars 5.49k forks source link

Badge request: Discord Bot List upvote count #4257

Open pedrofracassi opened 4 years ago

pedrofracassi commented 4 years ago

:clipboard: Description

top.gg (a.k.a. Discord Bots or DBL) is probably the biggest list of Discord bots out there. They allow users to upvote their favorite bots. This PR proposes a badge that shows how many upvotes a bot has.

:link: Data

They have a public API endpoint for getting information about a specific bot (documentation here). SVG scraping is also an option, but I don't see a reason to do it if JSON is available.

:microphone: Motivation

Many open-source bots have hosted instances, often listed on top.gg. These badges could be added to their repositories.

pedrofracassi commented 4 years ago

Assign this one to me please?

calebcartwright commented 4 years ago

Thanks for the suggestion and interest in working on this @pedrofracassi.

Ping us on this thread and/or Discord if you have any questions along the way!

pedrofracassi commented 4 years ago

I just logged out of my top.gg account. The API seems to need Authorization :/ Should I scrape the SVG then?

calebcartwright commented 4 years ago

The API seems to need Authorization :/ Should I scrape the SVG then?

That depends.

There's a few upstream services Shields integrates with that provide the data Shields needs via JSON APIs that require authentication, but have pretty broad authorization scope (for example SymfonyInsight, Bintray, and Wheelmap). With those, it's basically a scenario where as long as you're authenticated with an account then you're authorized to access all/most the public data. We create a Shields-owned account with the service, and then use the tokens/creds/etc. for that account when deploying Shields.io

Where it gets problematic is in cases where the authorization is narrowly scoped to a specific account/user/etc. and the other thing we have to be mindful of when authentication is required is whether the service rate limits requests.

Do you have any links to the API docs? (sorry I missed it in your OP - https://top.gg/api/docs#bots)

pedrofracassi commented 4 years ago

Yeah, the data on the API is available to anyone with an account and an API key. The rate limit seems to be 60 requests/minute. https://top.gg/api/docs#ratelimits

pedrofracassi commented 4 years ago

About the SVG, they seem to be using paths instead of <text> for their text. Is there a way to still parse it? https://top.gg/api/widget/upvotes/264811613708746752.svg?noavatar=true

calebcartwright commented 4 years ago

About the SVG, they seem to be using paths instead of <text> for their text. Is there a way to still parse it?

👀 yikes, I'm not sure, though imagine other maintainers would

pedrofracassi commented 4 years ago

Can we scrape web pages?

calebcartwright commented 4 years ago

Can we scrape web pages?

No we cannot. In order for Shields to provide badges for an upstream service or platform, the data has to be available via an API (in JSON or XML format) or via an SVG file