go4cas
go4cas

Reputation: 1191

GitHub API - List of Languages

Is there an endpoint in the GitHub API that will provide me with a list of ALL the languages on GitHub? I'm looking for similar results to the Languages drop-down in the "Trending" section on the github.com website.

Upvotes: 3

Views: 2966

Answers (2)

siduck
siduck

Reputation: 3

Use a yaml parser to parse all supported languages by github ( their linguistic.yml file )

npm i js-yaml
import { load } from "js-yaml";
let result = []

const getLangs = () => {
  fetch(
    "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml",
  )
    .then((response) => response.text())
    .then((yamlString) => load(yamlString))
    .then((data) => {
      for (let key in data) {
        if (data[key].aliases) result = result.concat(data[key].aliases);
      }

    })
    .catch((err) => console.log(err));
    
return result
};

Upvotes: 0

VonC
VonC

Reputation: 1323753

Not from GitHub API directly.

The OP AgileAce adds in the comments:

I've discovered that there is a Linguist library maintained by GitHub.
In this repo, there is a YAML file (lib/linguist/languages.yml) containing all the languages, and related info.
I'm just going to write a script that will parse this file.

I mentioned the linguist library in "How does github figure out a project's language?".


You can also get that data from various GitHub statistic sites, like www.githubarchive.org:

See "Top Github Languages for 2013 (so far)", by ADAM BARD:

I just discovered the Github Archive, a dataset of Github events queryable using Google BigQuery. What fun! So I decided to count how many repositories have been created this year by language.

SELECT repository_language, count(repository_language) AS repos_by_lang
FROM [githubarchive:github.timeline]
WHERE repository_fork == "false"
AND type == "CreateEvent"
AND PARSE_UTC_USEC(repository_created_at) >= PARSE_UTC_USEC('2013-01-01 00:00:00')
AND PARSE_UTC_USEC(repository_created_at) < PARSE_UTC_USEC('2013-08-30 00:00:00')
GROUP BY repository_language
ORDER BY repos_by_lang DESC
LIMIT 100

coderstats.net could be a good source too, with its language section.

Upvotes: 6

Related Questions