Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

duck-duck-scrape

Snazzah172.3kMIT2.2.7TypeScript support: included

Search from DuckDuckGo and use it's spice APIs.

duckduckgo, ddg, search, api

readme

NPM version NPM downloads ESLint status DeepScan grade

npm install duck-duck-scrape - yarn add duck-duck-scrape

Search from DuckDuckGo and utilize its spice APIs for things such as stocks, weather, currency conversion and more!

Available Features

  • Search
    • Regular search
    • Image search
    • Video search
    • News search
  • Stocks (via Xignite)
  • Time for Location API (via timeanddate.com)
  • Currency Conversion (via XE)
  • Forecast (via Dark Sky)
  • Dictionary
    • Definition
    • Audio
    • Pronunciation
    • Hyphenation

Quickstart

JavaScript

const DDG = require('duck-duck-scrape');
const searchResults = await DDG.search('node.js', {
  safeSearch: DDG.SafeSearchType.STRICT
});

// DDG.stocks('aapl')
// DDG.currency('usd', 'eur', 1)
// DDG.dictionaryDefinition('happy')

console.log(searchResults);
/**

{
  noResults: false,
  vqd: '3-314...',
  results: [
    {
      title: 'Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript...',
      ...
      url: 'https://nodejs.org/',
      bang: {
        prefix: 'node',
        title: 'node.js docs',
        domain: 'nodejs.org'
      }
    },
    ...
  ]
}

*/

TypeScript

import { search, SafeSearchType } from 'duck-duck-scrape';
// import * as DDG from 'duck-duck-scrape';

const searchResults = await search('node.js', {
  safeSearch: SafeSearchType.STRICT
});

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

2.2.7 - 2025-01-09

Fixed:

  • Updated search regex to account for response changes

    2.2.6 - 2024-11-22

    Changed:

  • ss_mkt is now replaced with bing_market which should allow for fewer anomalies (#141)

    2.2.5 - 2023-12-04

    Fixed:

  • Added request anomaly detection (#135)

    2.2.4 - 2023-05-11

    Fixed:

  • Updated VQD fetching

    2.2.3 - 2023-02-14

    Fixed:

  • Fixed build of last release

    2.2.2 - 2023-02-14

    Fixed:

  • Updated VQD fetching

    2.2.1 - 2022-02-02

    Fixed:

  • Improved web safe search filter (#33)

    2.2.0 - 2021-10-26

    Added:

  • Thesaurus spice
  • Emojipedia spice
  • Statista spice
  • ExpandUrl spice

    2.1.5 - 2021-09-29

    Fixed:

  • Fixed searchImages to use ensureJSON

    2.1.4 - 2021-09-15

    Fixed:

  • Fixed typings for forecast spice API

    2.1.3 - 2021-09-13

    Fixed:

  • Search news and videos sanity checking

    2.1.2 - 2021-08-08

    Fixed:

  • License filter in searchImages is now being properly used

    2.1.1 - 2021-08-07

    Fixed:

  • Fixed noResults being incorrect in images/news/videos

    2.1.0 - 2021-06-03

    Added:

  • DNS spice

    Fixed:

  • SearchTimeType is now exported to index

    2.0.1 - 2021-04-29

    Fixed:

  • Fixed no results parsing in search()

    2.0.0 - 2021-04-19

    Complete rewrite of the package, read the documentation before updating.

    Added:

  • Type definitions
  • Filters within searches (i.e. license, time range, etc.)

    Changed:

  • Uses JS endpoints rather than scraping webpages

    1.0.3 - 2018-04-07

  • Initial(-ish) release.