Get repository languages with the GitLab API

I would like to know if there is a way to get the languages (percentage per language) used in a project by using the API provided by GitLab. I checked their documentation but I didn't see anything about that or maybe I missed it.

I know that they use the Linguist library but I'm developping an application that's is not in Ruby and I'm looking for a way to integrate theses percentages.

Upvotes: 3

Views: 6041

Answers (2)

Justin T.
Justin T.

Reputation: 3701

As of 10.8.x, Gitlab added a new API entrypoint, exposing languages used in a specific repository.

Usage is straight forward :

curl --header "PRIVATE-TOKEN: <__ACCESS_TOKEN__>" https://gitlab.mydomain.com/api/v4/projects/<ID>/languages

docs : https://docs.gitlab.com/ee/api/projects.html#languages

Hope this helps!

Upvotes: 12

Jawad
Jawad

Reputation: 4665

Looks like there's no endpoint to do this right now as the data for language repartition is sent in inline javascript. But it might become available as they refactor the code (see this and this)

Upvotes: 4

Related Questions