No description, website, or topics provided.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
src
test
.gitignore
.travis.yml
Readme.md
gulpfile.js
package.json
tslint.json
yarn.lock

Readme.md

Yet another node lib for requesting Duck Duck Go.

This one has been written in typescript (2.x or above) and can be used by javascript (es6 or above) software or by typescript software.

Examples

  • TypeScript:
import { Requester } from "node-duckduckgo";
const requester = new Requester("node-duckduckgo-example");
requester.request("bart simpsons", (err, response, body) => {
  if (err) {
    console.log(err);
    return;
  }
  console.log(body);
});
  • Javascript:
const { Requester } = require("node-duckduckgo");
const requester = new Requester("node-duckduckgo-example");
requester.request("bart simpsons", (err, response, body) => {
  if (err) {
    console.log(err);
    return;
  }
  console.log(body);
});

API

  • The requester object takes an application name in parameter:
const requester = new Requester(<YOUR APP NAME>);
  • If needed, configure the requester options:
requester.no_html = 1;
requester.no_redirect = 1;

(for information about this options see Duck Duck GO API documentation

  • Execute your request and et your result This lib is backed by Request. Results can be got by either by Request's call back or by stream:
requester.request("bart simpsons", (err, response, body) => {
 if (err) {
   console.log(err);
   return;
 }
 console.log(body);
});
requester.request("bart simpsons")
  .on("data", (data) => {
    console.log(data.toString());
  })
  .on("error", (err) => {
    console.log(err);
  });

Response format is the Duck Duck GO response

Usage

node-duckduckgo is open sources (MIT license) but it doe grant you to use Duck Duck Go. Please read this page before any usage.