Omar1983
Omar1983

Reputation: 31

How to search repositories with github api v3 based on language and user name

I am trying to search for repositories based on the language "java" and user name "atermenji" (as an example). I get a different result when I search with the code search page of github https://github.com/search?utf8=%E2%9C%93&q=language%3Ajava+user%3Aatermenji&type=Repositories&ref=searchresults

When I try to do the same search with the api I get a different result.

curl -H 'Accept: application/vnd.github.preview.text-match+json' https://api.github.com/search/repositories?q=language:java&user=atermenji

There seems to be a problem in using the two parameters together as well. It seems like it is searching only based on the language not the user. Please advice.

Thanks.

Upvotes: 3

Views: 4574

Answers (1)

ogbeks
ogbeks

Reputation: 327

Try this to get all user repositories.

https://api.github.com/users/:username/repos

To my own understanding, the GitHub API get all repositories of a user but not with languages. It is important to understand that most repos have different languages hence from the GitHub API documentation, the parameters allow for searching user repo are the type, sort and direction of which there is no parameter for language for now.

To get a specific language of a repository, try:

GET /repos/:owner/:repo/languages

Upvotes: 2

Related Questions