Martin Schäf
Martin Schäf

Reputation: 375

Use GitHub API to find most popular Java projects but not JavaScript

I'm trying to do some machine learning on API usage. For that, I want to find some instances of GitHub repos that contain plain Java (non-Android) projects that match certain keywords. Let's say my query is sth like this:

https://api.github.com/search/repositories?q=foobar&language:Java&sort=stars&order=desc

which should show me all (or the top 30) projects containing the word "foobar" written in Java sorted by number of stars. However, "language:Java" also lets all JavaScript project through. Is there a better way to say that I want "Java" and not something that contains "Java" as a language?

Beyond that, I'd like to exclude android projects which is a bit trickier, I guess. But is there a way to say, e.g. exclude everything that has "android" in the description/readme?

Upvotes: 0

Views: 321

Answers (1)

Chris
Chris

Reputation: 136910

This endpoint only supports three parameters: q, sort, and order. The language should be submitted as part of the q parameter, i.e. joined to it with + instead of separated with &:

https://api.github.com/search/repositories?q=foobar+language:Java&sort=stars&order=desc

See the example query for another example.

Upvotes: 1

Related Questions