Github Java API - search repos
github-api
Solution
Try jcabi-github (I'm one of its developers):
final Github github = new RtGithub();
final JsonResponse resp = github.entry()
.uri().path("/search/repositories")
.queryParam("q", "java").back()
.fetch()
.as(JsonResponse.class);
final List<JsonObject> items = resp.json().readObject()
.getJsonArray("items")
.getValuesAs(JsonObject.class);
for (final JsonObject item : items) {
System.out.println(
String.format(
"repository found: %s",
item.get("full_name").toString()
)
);
}
Full example is here: https://github.com/jcabi/jcabi-github/tree/master/examples/search-repos
Problem
I want to search Github repos based on size and keyword parameters. Here is the Java code I wrote: ``` package searchTest; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.egit.github.core.SearchRepository; import org.eclipse.egit.github.core.client.GitHubClient; import org.eclipse.egit.github.core.service.RepositoryService; public class GithubSearch { private static Map<String, String> searchQuery = new HashMap<String, String>(); public static void main(String[] args) throws IOException { GitHubClient client = new GitHubClient(); client.setCredentials("username", "password"); RepositoryService service = new RepositoryService(client); searchQuery.put("keyword","microsoft"); searchQuery.put("size","304"); List<SearchRepository> searchRes = service.searchRepositories(searchQuery); System.out.println("Search result "+searchRes.toString()); } } ``` But the output I get is empty: ``` Search result [] ``` I checked the GitHub Java API javadoc, but could not find a solution. Thanks!