0

Is there any way to access the GitHub Wiki with Java?
Let's take this site: https://github.com/radiant/radiant/wiki. How can I retrieve all possible information like links, titles, descriptons, etc.? Is there any API?

Here Can I checkout github wikis like a git repository? it says, I can clone the Wiki now. Is it possible to use jGit to access it then?

Community
  • 1
  • 1
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181

2 Answers2

0

Yes, you can do this by submitting a cURL request to the github API that is documented here: https://developer.github.com/v3/.

EX:

curl -G https://api.github.com/repos/{repo-owner}/{repo-name}

(where in your case repo-name and owner are both radiant)

This will return a JSON object with a bunch of links to fetch whatever information you want associated with the repo.

I know offhand that there is a short description field in the response, as well as a bunch of *_url fields that contain urls to fetch other pieces of information associated with the repo like contents_url, comments_url, git_tags_url, and many more.

To access these you would just send a similar get request to the one above to the url stored in the field.

If you need information on how to make cURL requests in java, there's a a good SO post on it already here.

Community
  • 1
  • 1
Jake
  • 29
  • 3
  • Ok, I'm able to access global information of the project like id, name, avatar_url, etc. But what about the specific information on the wiki page? In my example it would be "Installation", "The Basics", etc. and the corresponding descriptions? – Evgenij Reznik Jul 30 '14 at 11:29
  • I've been able to get it using a not so elegant solution.... You can send a get request to the original URL you sent me and then get back an html representation of the page. The response will be the entire page, but you can find the main content in a div with id="wiki-content" and then scrape the text out of the inner html elements. Like I said at first, this won't be a very pretty solution. – Jake Jul 30 '14 at 17:04
  • Is there any api to provide me with a more elegant solution? – Evgenij Reznik Jul 30 '14 at 18:57
0

Unfortunately wiki details are not available through the GitHub API.

They are however available as a repository which you can clone locally:

sidebar

For example: git clone https://github.com/radiant/radiant.wiki.git

This will give you the raw Markdown pages and the history of changes.

Brendan Forster
  • 2,548
  • 1
  • 24
  • 32