github-readme-stats
github-readme-stats copied to clipboard
[Feature Request] Add organization stats
Most of my open-source work is moved to dedicated organizations (47ng, FortySevenEffects, Chiffre), for scoping and to avoid cluttering my personal repos.
I'd be happy to contribute a feature to include aggregated organization stats.
API ideas:

@franky47 great idea! okay i will look into it. and try to add org support. meanwhile you can also contribute if you want.
I did that in my fork on AWS Lambda. For the pin.js I did:
query: `
fragment RepoInfo on Repository {
name
owner {
login
}
const renderRepoCard = (repo) => {
const owner = repo.owner.login;
<text x="50" y="38" class="header"><a class="header" href="https://github.com/${owner}/${name}">${name}</a></text>
You can see too that I added an <a> link to the repo name too.
Will it actually show the stats including all the Orgs?
@metaskills Also yes that link would work but will it work in github readmes? Hmmm i dont think soo because it is served as image not as raw html elements. 🤔
Oh yea... good point. Without a in your markdown, you can click it (views svg) then click it again. But easier to put the links in your markdown I suspect.
Yes just wrapping the markdown image inside a link is a good way.
I really hope to have this function, which can count my stars in the organization!
my stars value is 0, can help check?
https://github-readme-stats.vercel.app/api/?username=deancn
Hi @deancn, it is because we currently only support stars from repositories you are the owner of. Since many people want this as an enhancement I'm sure we'll be able to implement this soon.
@terror got it, thanks.
Assuming you might be a member of some huge organization (npm, babel, rust). It might make sense to add a filter on top of it to prevent certain organizations from being included. Better than that would be an allowlist that only includes organizations that you explicitly declare:
https://github-readme-stats.vercel.app/api/?username=SirWindfield?orgs=zors-engine,Spotifyd
How long this feature could be used?
any news on this?
Any update on this?
@anuraghazra I tried it in go and it worked like a charm to count those stars:
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Org struct {
Name string `json:"login"`
}
type Repo struct {
Name string `json:"full_name"`
Stars int `json:"stargazers_count"`
}
func main() {
url := "https://api.github.com/users/mattetti/orgs"
resp, err := http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var stars int
var orgs []Org
json.Unmarshal(body, &orgs)
for _, v := range orgs {
url = fmt.Sprintf("https://api.github.com/orgs/%s/repos", v.Name)
resp, err = http.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
var repos []Repo
json.Unmarshal(body, &repos)
for _, v := range repos {
fmt.Println(v.Name, v.Stars)
stars += v.Stars
}
}
fmt.Println("-----------------------")
fmt.Println("### Total stars:", stars)
}
It's quite simple: you just get all org names from the api endpoint /users/${USERNAME}/orgs and then get all each repo from each org from the endpoint /orgs/${ORGNAME}/repos. Just count those stars together and you have it. But since I don't have the expierence in javascript I won't be able to implement this.
@ngoldack
this api /users/${USERNAME}/orgs seemingly inaccurate
for example https://api.github.com/users/Mr-jiangzhiguo/orgs get [],
but in fact, it has 3 public orgs

@Mr-jiangzhiguo, strangely when I go to your Github profile, I also can't see your organizations.
I tried mine (curl https://api.github.com/users/mre/orgs) and it works. 🤔
@Mr-jiangzhiguo, strangely when I go to your Github profile, I also can't see your organizations. I tried mine (
curl https://api.github.com/users/mre/orgs) and it works. 🤔
I got it, settings is private

It's quite simple: you just get all org names from the api endpoint /users/${USERNAME}/orgs and then get all each repo from each org from the endpoint /orgs/${ORGNAME}/repos. Just count those stars together and you have it. But since I don't have the expierence in javascript I won't be able to implement this.
Yeah logic isn't an issue here. we can of course get the data and manipulate it as per our needs.
BUT! The issue is that vercel serverless execution time is only 10sec and it's not enough to fetch all those data & then manipulate it, serverless function would time out long before we even get to fetching all org data.
and then get all each repo from each org
And this is also very expensive because the organization can have many repos and we have to fetch all of them and accumulate the star count.
@anuraghazra some kind of lightweight cache could be a solution 🤔
@anuraghazra or concurrency.
Another problem would be the rate limiting with too much orgs/repos
some kind of lightweight cache could be a solution thinking
We already have caching, it's not the issue since the initial data wont even load because vercel would timeout.
the same demands
eager to have this.
Patiently waiting for an exciting update.
I would prefer to use a whitelist for that, that would also make it more straight forward and light (probably?)
For example:
https://github-readme-stats.vercel.app/api?username=MrTroble&?orgs=Troblecodings&show_icons=true&theme=radical
This would go through the repos of Troblecodings and would account for all stars in those. This shouldn't take to long should it?
Still relevant.
Just bought @anuraghazra a coffee in the name of this issue (and as a general "thank you" for making this wonderful piece of software). Maybe if more people chip in we can convince him to get this done before he gets a heart attack from all the caffeine. 😅
Just bought @anuraghazra a coffee in the name of this issue (and as a general "thank you" for making this wonderful piece of software). Maybe if more people chip in we can convince him to get this done before he gets a heart attack from all the caffeine. 😅
😄 haha thank you for coffee.
Well yeah probably only viable way to get this issue done is to change the fetching system, like instead of fetching on the fly with serverless functions, we can create a github action to fetch the data, this way serverless functions won't timeout and we can fetch more data looping over all the organizations.
What is the status of this Feature?