A small Java client for the Diffbot Article API — point it at a web page and get back the extracted article as a typed object rather than raw HTML.
Archived. Written in 2014 against Diffbot API v2, which has since been superseded. Kept as a reference for the shape rather than something to depend on.
DiffbotApi api = new DiffbotApiImpl();
ArticleResponse article = api.article(token, "http://example.com/some-story");
System.out.println(article.getTitle());
System.out.println(article.getText());token is your Diffbot API token.
Four classes, deliberately:
| Class | Role |
|---|---|
DiffbotApi |
Interface — one method, article(token, url), plus the base URL constant |
DiffbotApiImpl |
Builds the request URL, calls it, deserialises the JSON with Gson |
HttpClient |
Plain GET over HttpURLConnection |
ArticleResponse |
The response mapped to fields |
Only the Article endpoint is covered. Diffbot offers others — Frontpage, Product, Image — and adding one means a method on the interface plus a matching response model; the client was structured with that in mind, but the rest were never needed.
mvn package
Depends on Gson. Tests in DiffbotApiTest call the live API, so they need a valid token.