A GitHub search engine for CS209A project backend application
This engine provides basic functionalities for querying GitHub repositories
, topics
, codes
and users
with specific keywords
,
qualifiers
and options
, and supports java abstractions for repos
, users
, topic
, code segments
, content files
, content directories
, etc.
The engine interacts with GitHub REST API to provide the service, and it relies on the OAuthToken
provided by the end user.
You can find the related javadoc under /docs inside the repository.
Or you can check GitHub Search Engine API doc, which is hosted on GitHub.io
Now supports querying multiple tokens to maximize the performance.
You need the OAuthToken
to register the engine.
GitHubAPI gitHubAPI = GitHubAPI.registerAPI(OAuthtoken);
For example, suppose you want to search all pom.xml
files containing keyword log4j
in GitHub,
with language=Maven POM
, and creation date before Jan 3, 2022:
//Build a request
SearchRequest request = CodeSearchRequest
.newBuilder()
.addSearchKeyWord("log4j")
.addSearchField(CodeSearchRequest.SearchBy.Filename, "pom.xml")
.addLanguageOption("Maven POM")
.addDateOption(CodeSearchRequest.DateOption.Created, "2022-01-03", "<=")
.build();
SearchRequest req1 = RepoSearchRequest.newBuilder()
.addSearchKeyword("Data")
.addSearchField(RepoSearchRequest.SearchBy.Topic, "java")
.addDateOption(RepoSearchRequest.DateOption.Created, "2012-01-01", ">=")
.build();
SearchRequest req2 = TopicSearchRequest.newBuilder()
.addSearchKeyword("Java")
.addSearchKeyword("Data")
.addSearchKeyword("Visualization")
.build();
...etc.
TopicResult result = gitHubAPI.searchAPI.searchTopic(req2, 100);