I have an url to github repo, for instance: https://github.com/dotnet/corefx
Is there any possible approach in github's API to get "C#" as a primary language of the repository?
I have an url to github repo, for instance: https://github.com/dotnet/corefx
Is there any possible approach in github's API to get "C#" as a primary language of the repository?
You can use List languages Github API that will give you all language used in this repo with the number of bytes of code written in that language :
GET https://api.github.com/repos/dotnet/corefx/languages
that will give you :
{
"C#": 131055040,
"C": 1078381,
"Visual Basic": 829607,
"C++": 622926,
"XSLT": 462336,
"OpenEdge ABL": 139178,
"Shell": 70286,
"CMake": 60136,
"PowerShell": 51624,
"DIGITAL Command Language": 26402,
"Groovy": 25726,
"Batchfile": 21796,
"Objective-C": 9455,
"Makefile": 9085,
"Roff": 4236,
"Perl": 3895,
"ASP": 1687,
"Python": 1535,
"1C Enterprise": 903,
"HTML": 653
}
With bash you can use jq
to parse and select the field with the max bytes value :
language=`curl -s https://api.github.com/repos/dotnet/corefx/languages | jq 'to_entries | max_by(.value) | .key'`
echo "$language"
you can find the docs for the list of languages here
GET https://api.github.com/repos/microsoft/vscode/languages
and you can also find the most used language in the repo if you do a normal repo request under the language
property
GET https://api.github.com/repos/microsoft/vscode
© 2022 - 2025 — McMap. All rights reserved.