npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

diffbot-coffee

v0.1.0

Published

Diffbot API Wrapper

Downloads

9

Readme

Diffbot API for CoffeeScript

Preface

This brief documentation doesn't include full API methods and parameters. Full library API documentation in HTML format could be found in doc folder.

Installation

Library can be installed from npm

npm install diffbot-coffee

Configuration

Obtaining CoffeeScript Diffbot client is simple as that:

{Client} = require 'diffbot-coffee'
client = new Client '<your_key>'

Usage

Article API

Assume that we have our client configured. In order to use Automatic Article API we need to instantiate Article API instance first:

article = client.article 'http://someurl.com', ['title']

After instantiation we can use our client object to retrieve information

article.load (error, result) ->
  if error?
    console.error error
  else
    console.log result

If your content is not publicly available (e.g., behind a firewall), you can use send method or article object

article = client.article 'http://diffbot.com', ['title']
content = '<html><head><title>Test title</title></head><body>Test body</body></html>'
article.send content, (error, result) ->
  if error?
    console.error error
  else
    console.log result

There is also alternative syntax for creating article objects

article = client.article
              url: 'http://someurl.com'
              fields: ['title']
console.log article.url
console.log article.relative_url
article.load (error, result) ->  
  if error?
    console.error error
  else
    console.log result.type

Similar syntax is available for all objects.

Page Classifier API

Calling Page Classifier API is also pretty simple:

pageclassifier = client.pageclassifier 'http://someurl.com'
pageclassifier.load (error, result) ->
  if error?
    console.error error
  else
    console.log result.type

Crawlbot API

Calling Crawlbot API is similar to calling Article API. One thing worth to notice is that Crawlbot API Version 2 requires apiUrl which will be used to perform crawling. Library implementation makes possible to avoid using urls here. Instead we will use Article API:

crawler = client.crawlbot 'my-bot', ['http://someurl.com', 'http://foo.com'], client.article('', ['title']).url
crawler.create (error, result) ->
  if !error?
    console.log result

or alternatively we can set optional parameters as object

crawler = client.crawlbot 'my-bot',
                seeds: ['http://someurl.com', 'http://foo.com']
                apiUrl: client.article('', ['title']).url

crawler.create (error, result) ->
  if !error?
    console.log result

Crawler object supports next methods

crawler.pause
crawler.restart
crawler.delete
crawler.data
crawler.status

Usage is pretty simple

or alternatively we can set optional parameters as object

crawler = client.crawlbot 'my-bot',
                seeds: ['http://someurl.com', 'http://foo.com']
                apiUrl: client.article('', ['title']).url

crawler.create (error, result) =>
  if !error?
    crawler.delete (error, result) =>
      if !error? and result
        console.log 'Crawler successfully deleted'