A Dart client library for Diffbot APIs
Published October 14, 2013
I wrote a Dart client library for Diffbot, which is a visual learning robot that identifies and extracts the important parts of any web page. In the case of an article, Diffbot returns title, author, images, tags, etc.
This library can be used both in the browser that in the console, and can talk to three of the main APIs:
Article API, used to extract clean article text from news article web pages
Frontpage API, it takes in a multifaceted “homepage” and returns individual page elements.
Product API, it analyzes a shopping or e-commerce product page and returns information on the product.
diffbot: any to your app’s pubspec file, then run
To use it in a web app:
To use it in a command-line app:
First of all, you have to create a new Client instance, which takes a diffbot token as an argument, you can grab a token at diffbot.com/pricing, they also offer a free developer token for non-commercial use.
Now you’re ready to use on of client’s methods, such as
Those methods return a Future, let’s say you want to get important parts of an article, your code will be like this:
Here are three live examples, one for each API:
This will show Title, Author, Date and of course Content for three articles; you can also submit your own article.
Shows the Hacker News frontpage.
Shows Title, Price and images for three products; you can also submit your own product.
You can find more examples in the
example directory of the github repository.
Source code, documentation and bug reporting
Source code: github.com/claudiodangelis/diffbot.
Official Diffbot APIs documentation: diffbot.com/products.
Library documentation: claudiodangelis.com/docs/diffbot.
To file a bug please open a new issue on github.
Needless to say that contributions and feedbacks are always welcome :)