{"id":22000760,"url":"https://github.com/irevenko/octostats","last_synced_at":"2025-05-01T02:48:14.789Z","repository":{"id":52934656,"uuid":"345684653","full_name":"irevenko/octostats","owner":"irevenko","description":"🐙🐱📦 Additional GitHub API methods","archived":false,"fork":false,"pushed_at":"2021-04-13T10:07:13.000Z","size":221,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-01T02:48:03.345Z","etag":null,"topics":["github","github-api","github-app","github-profile","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/irevenko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-08T14:30:54.000Z","updated_at":"2023-12-05T15:04:48.000Z","dependencies_parsed_at":"2022-09-17T15:42:22.674Z","dependency_job_id":null,"html_url":"https://github.com/irevenko/octostats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevenko%2Foctostats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevenko%2Foctostats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevenko%2Foctostats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irevenko%2Foctostats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irevenko","download_url":"https://codeload.github.com/irevenko/octostats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251815442,"owners_count":21648367,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-api","github-app","github-profile","go","golang"],"created_at":"2024-11-29T23:11:02.790Z","updated_at":"2025-05-01T02:48:14.767Z","avatar_url":"https://github.com/irevenko.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# octostats 🐙🐱📦\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/irevenko/octostats.svg)](https://pkg.go.dev/github.com/irevenko/octostats)\n\n\u003e A supplementary Go package on top of \u003ca href=\"https://github.com/google/go-github\"\u003ego-github\u003c/a\u003e and \u003ca href=\"https://github.com/shurcooL/githubv4\"\u003egithubv4\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"octo-gopher.png\" width=\"300\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eGitHub API Superstructure\u003c/p\u003e \u003cbr\u003e\n\n# Installation 🔨\n```go get github.com/google/go-github``` \u003cbr\u003e\n```go get github.com/google/go-querystring``` \u003cbr\u003e\n```go get github.com/shurcooL/githubv4``` \u003cbr\u003e\n```go get golang.org/x/oauth2``` \u003cbr\u003e \u003cbr\u003e\n\n```go get github.com/irevenko/octostats```\n\n# Methods 🧰\n* [REST](#REST \"Goto #REST\")\n\t* [AllRepos](#AllRepos \"Goto ##AllRepos\")\n\t* [LanguagesByRepo](#LanguagesByRepo \"Goto ##LanguagesByRepo\")\n\t* [MostUsedLicenses](#MostUsedLicenses \"Goto ##MostUsedLicenses\")\n\t* [MostStarredRepos](#MostStarredRepos \"Goto ##MostStarredRepos\")\n\t* [MostForkedRepos](#MostForkedRepos \"Goto ##MostForkedRepos\")\n\t* [StarsPerLanguage](#StarsPerLanguage \"Goto ##StarsPerLanguage\")\n\t* [ForksPerLanguage](#AllRepos \"Goto ##ForksPerLanguage\")\n\t* [TotalStars](#TotalStars \"Goto ##TotalStars\")\n\t* [TotalForks](#TotalForks \"Goto ##TotalForks\")\n* [GraphQL](#GraphQL \"Goto #GraphQL\")\n\t* [LanguagesByCommit](#LanguagesByCommit \"Goto ##LanguagesByCommit\")\n\t* [AllContributions](#AllContributions \"Goto ##AllContributions\")\n\t* [AllCommits](#AllCommits \"Goto ##AllCommits\")\n\t* [AllIssues](#AllIssues \"Goto ##AllIssues\")\n\t* [AllPullRequests](#AllPullRequests \"Goto ##AllPullRequests\")\n\t* [YearActivity](#YearActivity \"Goto ##YearActivity\")\n\t* [UserDetails](#UserDetails \"Goto ##UserDetails\")\n\t* [OrganizationDetails](#OrganizationDetails \"Goto ##OrganizationDetails\")\n\n# Docs 📋\nGo Reference: https://pkg.go.dev/github.com/irevenko/octostats\n# REST\nAll examples are using ```AuthREST``` \u003cbr\u003e\n```ctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")```\n\nIf you want you can write your own auth but keep in mind that you in order to use this package ```client, context``` are required\n\n\n## AllRepos\nReturns slice of repos for user/organization (https://api.github.com/users/USERNAME/repos)\n```go\nimport ( \n    \"fmt\"\n    \"log\"\n\n    \"github.com/google/go-github/github\"\n    r \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(allRepos)\n}\n```\n\n## LanguagesByRepo\nReturns two slices of names and occurrences\n```go\nimport ( \n    \"fmt\"\n    \"log\"\n    \"strconv\"\n\n    \"github.com/google/go-github/github\"\n    r \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\n\tusedLangs, langsNum := r.LanguagesByRepo(client, allRepos)\n\tfmt.Println(\"Languages By Repo\")\n\tfor i, v := range usedLangs {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(langsNum[i]))\n\t}\n}\n```\n\n## MostUsedLicenses\nReturns two slices of names and occurrences\n``` go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\n\tusedLicenses, licsNum := r.MostUsedLicenses(client, allRepos)\n\tfmt.Println(\"Most used licenses\")\n\tfor i, v := range usedLicenses {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(licsNum[i]))\n\t}\n}\n```\n\n## MostStarredRepos\nReturns two slices of names and stars num\n``` go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\t\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n    \n\tstarredRepos, starredNums := r.MostStarredRepos(client, allRepos)\n\tfmt.Println(\"Most starred repos\")\n\tfor i, v := range starredRepos {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(starredNums[i]))\n\t}\n}\n```\n\n## MostForkedRepos\nReturns two slices of names and forks num\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n    \n\tforkedRepos, forkedNums := r.MostForkedRepos(client, allRepos)\n\tfmt.Println(\"Most forked repos\")\n\tfor i, v := range forkedRepos {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(forkedNums[i]))\n\t}\n}\n```\n\n## StarsPerLanguage\nReturns two slices of languages and stars num\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n    \n\tstarsPerL, starsNum := r.StarsPerLanguage(client, allRepos)\n\tfmt.Println(\"Stars per lang\")\n\tfor i, v := range starsPerL {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(starsNum[i]))\n\t}\n}\n```\n## ForksPerLanguage\nReturns two slices of languages and forks num\n```go\nimport ( \n \t\"fmt\"\n\t\"log\"\n\t\"strconv\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\n\tforksPerL, forksNum := r.ForksPerLanguage(client, allRepos)\n\tfmt.Println(\"Forks per lang\")\n\tfor i, v := range forksPerL {\n\t\tfmt.Println(v + \": \" + strconv.Itoa(forksNum[i]))\n\t}\n}\n```\n\n## TotalStars\nReturns integer number\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n    \n\ttotalStars := r.TotalStars(client, allRepos)\n\tfmt.Println(\"Total stars\")\n\tfmt.Println(totalStars)\n}\n```\n\n## TotalForks\nReturns integer number\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/google/go-github/github\"\n\tr \"github.com/irevenko/octostats/rest\"\n)\n\nfunc main() {\n\tctx, client := r.AuthREST(\"\u003cYOUR_TOKEN\u003e\")\n\t\n\tallRepos, err := r.AllRepos(ctx, client, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n    \n\ttotalForks := r.TotalForks(client, allRepos)\n\tfmt.Println(\"Total forks\")\n\tfmt.Println(totalForks)\n}\n```\n\n# GraphQL\nAll examples are using ```AuthGraphQL``` \u003cbr\u003e\n```client := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")```\n\nIf you want you can write your own auth but keep in mind that you in order to use this package ```client``` is required\n\n## LanguagesByCommit\nReturns two slices of languages and commits \u003cbr\u003e\n```from``` and ```to``` must be within 1 year span (2009, 2010 OR 2014, 2015 etc...)\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tlangs, commits, err := g.LanguagesByCommit(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\", 2020, 2021)\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"\\nLanguages by commit\")\n\tfor i, v := range langs {\n\t\tfmt.Printf(\"%v : %v\\n\", v, commits[i])\n\t}\n}\n```\n\n## AllContributions\nReturns ```ContributionsCollection``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go) \u003cbr\u003e\n```from``` and ```to``` must be within 1 year span (2009, 2010 OR 2014, 2015 etc...)\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallContribs, err := g.AllContributions(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\", 2020, 2021)\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"\\nAll contribs 2020-2021:\")\n\tfmt.Println(allContribs)\n}\n```\n\n## AllCommits\nReturns ```[]commitContributions``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go)\u003cbr\u003e\n```from``` and ```to``` must be within 1 year span (2009, 2010 OR 2014, 2015 etc...)\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallCommits, err := g.AllCommits(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\", 2020, 2021)\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"\\nAll commits 2020-2021:\")\n\tfmt.Println(allCommits)\n}\n```\n\n## AllIssues\nReturns ```[]issueContributions``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go)\u003cbr\u003e\n```from``` and ```to``` must be within 1 year span (2009, 2010 OR 2014, 2015 etc...)\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallIssues, err := g.AllIssues(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\", 2020, 2021)\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"\\nAll issues 2020-2021:\")\n\tfmt.Println(allIssues)\n}\n```\n\n## AllPullRequests\nReturns ```[]pullRequestContributions``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go)\u003cbr\u003e\n```from``` and ```to``` must be within 1 year span (2009, 2010 OR 2014, 2015 etc...)\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tallPrs, err := g.AllPullRequests(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\", 2020, 2021)\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(\"\\nAll pull requests 2020-2021:\")\n\tfmt.Println(allPrs)\n}\n```\n\n## YearActivity\nReturns two slices of dates and contributions \u003cbr\u003e\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tdates, contribs, err := g.YearActivity(qlClient, \"\u003cUSER_OR_ORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(dates, contribs)\n}\n```\n\n## UserDetails\nReturns ```User``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go)\u003cbr\u003e\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tfmt.Println(\"User Details:\")\n\tuserInfo, err := g.UserDetails(qlClient, \"\u003cUSER\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(userInfo)\n}\n```\n\n## OrganizationDetails\nReturns ```Organization``` (see https://github.com/irevenko/octostats/blob/main/graphql/types.go)\u003cbr\u003e\n```go\nimport ( \n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/shurcooL/githubv4\"\n\tg \"github.com/irevenko/octostats/graphql\"\n)\n\nfunc main() {\n\tqlClient := g.AuthGraphQL(\"\u003cYOUR_TOKEN\u003e\")\n\n\tfmt.Println(\"Organization Details:\")\n\torgInfo, err := g.OrganizationDetails(qlClient, \"\u003cORGANIZATION\u003e\")\n\tif err != nil {\n\t    log.Fatal(err)\n\t}\n\tfmt.Println(orgInfo)\n}\n```\n\n# Contributing 🤝\nContributions, issues and feature requests are welcome! 👍 \u003cbr\u003e\nFeel free to check [open issues](https://github.com/irevenko/octostats/issues).\n\n# What I Learned 🧠\n- GraphQL basics\n- GoLang API auth\n\n# Notes\n- shows private repos and repos from orgs when using empty string as name (if authorized)\n- see readme-stats, metrics\n\n# License 📑 \n(c) 2021 Ilya Revenko. [MIT License](https://tldrlegal.com/license/mit-license)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firevenko%2Foctostats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firevenko%2Foctostats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firevenko%2Foctostats/lists"}