This is a Java client library that you can use to search and retrieve documents from Wikipedia . It can be used in Android or any Java and Kotlin Project.
To use library in your gradle project follow the steps below:
- Add this in your root
build.gradle
at the end of repositories:allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
- Add the dependency
dependencies { def WIKIPEDIA4J_VERSION = "..." implementation "com.github.llmjava:wikipedia4j:$WIKIPEDIA4J_VERSION" }
To use the library in your Maven project, follow the steps below:
- Add the JitPack repository to your build file:
<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
- Add the dependency
<dependency> <groupId>com.github.llmjava</groupId> <artifactId>wikipedia4j</artifactId> <version>${WIKIPEDIA4J_VERSION}</version> </dependency>
Example code to use the Wikipedia API:
class App {
public static void main(String[] args) {
Wikipedia wiki = new Wikipedia();
List<Document> results = wiki.search("apple");
for(Document doc: results) {
System.out.println(doc);
}
}
}
Clone the repository and import as Maven project in IntelliJ IDEA or Eclipse
Before building the project, make sure you have the following things installed.
- Maven
- Java 8
To install the API client library to your local Maven repository, simply execute:
mvn install
To build the library using Gradle, execute the following command
./gradlew build
Refer to the official documentation for more information.