A powerful and easy-to-use Java client for interacting with Wattpad's API. This library allows developers to fetch stories, parts, and metadata from Wattpad, enabling seamless integration into your Java applications.
- Fetch Wattpad stories by ID or part ID.
- Retrieve metadata such as title, author, description, tags, and cover images.
- Render story parts with support for text and images.
- Built-in caching for optimized performance.
- Fully customizable client configuration.
- Java 17 or higher
- Maven or Gradle for dependency management
Here's an example of how to use the Wattpad API client to fetch and render a story:
import dev.advik.wattpad.WattpadClient;
import dev.advik.wattpad.models.Story;
public class Main {
public static void main(String[] args) {
WattpadClient client = new WattpadClient.Builder().useCache(true).build();
long storyId = 336166598L; // Example story ID
try {
Story story = Story.fromId(storyId, client);
System.out.println("Title: " + story.getTitle());
System.out.println("Author: " + story.getAuthor().getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
The library supports rendering story parts with text and images:
RenderedPage renderedPage = part.renderWith(client);
for (HTMLContent content : renderedPage.getContentStack()) {
if (content.getType() == HTMLContent.Type.TEXT) {
System.out.println(content.getTextData());
} else if (content.getType() == HTMLContent.Type.IMAGE) {
System.out.println("[IMAGE: " + content.getImageUrl() + "]");
}
}
Story story = Story.fromId(336166598L, client);
System.out.println("Title: " + story.getTitle());
System.out.println("Description: " + story.getDescription());
System.out.println("Author: " + story.getAuthor().getName());
System.out.println("Tags: " + story.getTags());
System.out.println("Cover URL: " + story.getCoverUrl());
client.clearCache();
System.out.println("Cache cleared.");
Clone the repository and build the project using Maven:
git clone https://github.com/your-username/Wattpad-API.git
cd Wattpad-API
mvn clean install
Run the Main.java
file to see the API in action:
java -cp target/wattpad-api-1.0.0.jar dev.advik.Main
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes and push them to your fork.
- Submit a pull request.
This project is licensed under the MIT License.
For questions or support, feel free to reach out:
- Author: Advik
- GitHub: github.com/Advik-B
- Wattpad
API DocumentationLMFAO WATTPAD DOES NOT HAVE DOCUMENTATION I HAD TO FIGURE ALL OF THIS OUT BY HAND- GitHub Repository