Is there any API in Java to access wikipedia data
Asked Answered
B

6

29

I want to know: is there any API or a query interface through which I can access Wikipedia data?

Busse answered 9/9, 2009 at 6:54 Comment(0)
C
22

Mediawiki, the wiki platform that wikipedia uses does have an HTTP based API. See MediaWiki API.

For example, to get pages with the title stackoverflow, you call

http://en.wikipedia.org/w/api.php?action=query&titles=Stackoverflow

There are some (incomplete) Java wrappers around the API - see the Client Code - Java section of the API page for more detail.

Champ answered 9/9, 2009 at 7:8 Comment(0)
V
8

For the use with Java, try http://code.google.com/p/wiki-java. It is only one class, but a great one!

Verge answered 31/5, 2012 at 9:1 Comment(0)
F
5

You can use Jwiki to get Wikipedia data Example :

Jwiki jwiki = new Jwiki("elon musk");
System.out.println("Title :"+jwiki.getDisplayTitle()); //get title
System.out.println("Text : "+jwiki.getExtractText());  //get summary text
System.out.println("Image : "+jwiki.getImageURL());    //get image URL
Fleurette answered 5/6, 2020 at 12:21 Comment(1)
Man You Rocked It Best API everParfait
D
4

I had the same question and the closest I came to an out-of-the-box solution is bliki, hosted at http://code.google.com/p/gwtwiki/. I also wrote an article at Integrating Stuff to help you get started with it: http://www.integratingstuff.com/2012/04/06/hook-into-wikipedia-using-java-and-the-mediawiki-api/

Dumah answered 6/4, 2012 at 17:53 Comment(0)
A
2

MediaWiki is a free and open-source wiki software. Originally developed by Magnus Manske and improved by Lee Daniel Crocker, it runs on many websites, including Wikipedia, Wiktionary and Wikimedia Commons.[5][6]

There is list of Java libraries that can help you to connect wiki by java code . https://www.mediawiki.org/wiki/API:Client_code#Java

but after use some of them because of their limitations , we try to call REST services from mediawiki directly.

Anthelmintic answered 17/1, 2018 at 13:53 Comment(0)
C
1

You can use wikipedia4j to search for documents like this

Wikipedia wiki = new Wikipedia();
List<Document> results = wiki.search("apple");
for(Document doc: results) {
  System.out.println(doc);
}
Convalesce answered 7/9, 2023 at 12:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.