Options
All
  • Public
  • Public/Protected
  • All
Menu

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
});

Index

Type aliases

AutocompleteResult

AutocompleteResult: AutocompleteTerm | AutocompleteBang

DictionaryDefinitionPartOfSpeech

DictionaryDefinitionPartOfSpeech: "noun" | "adjective" | "verb" | "adverb" | "interjection" | "pronoun" | "preposition" | "abbreviation" | "affix" | "article" | "auxiliary-verb" | "conjunction" | "definite-article" | "family-name" | "given-name" | "idiom" | "imperative" | "noun-plural" | "noun-posessive" | "past-participle" | "phrasal-prefix" | "proper-noun" | "proper-noun-plural" | "proper-noun-posessive" | "suffix" | "verb-intransitive" | "verb-transitive"

DictionaryHyphenationType

DictionaryHyphenationType: "stress" | "secondary stress"

DictionaryPronunciationType

DictionaryPronunciationType: "ahd-5" | "arpabet" | "gcide-diacritical" | "IPA"

ForecastAlertSeverity

ForecastAlertSeverity: "advisory"

ForecastIcon

ForecastIcon: "partly-cloudy-day" | "partly-cloudy-night" | "cloudy" | "rain" | "clear-day" | "snow" | "fog" | "clear-night" | "clear-day"

ForecastPrecipType

ForecastPrecipType: "rain" | "snow"

Search Functions

autocomplete

  • autocomplete(query: string, region?: string, needleOptions?: NeedleOptions): Promise<AutocompleteResult[]>
  • Get auto-complete terms from a query.

    Parameters

    • query: string

      The query to search

    • Optional region: string

      The region to search as

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<AutocompleteResult[]>

    Autocomplete terms

search

  • Search something.

    Parameters

    • query: string

      The query to search with

    • Optional options: SearchOptions

      The options of the search

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<SearchResults>

    Search results

searchImages

  • Search images.

    Parameters

    • query: string

      The query to search with

    • Optional options: ImageSearchOptions

      The options of the search

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<ImageSearchResults>

    Search results

searchNews

  • Search news articles.

    Parameters

    • query: string

      The query to search with

    • Optional options: NewsSearchOptions

      The options of the search

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<NewsSearchResults>

    Search results

searchVideos

  • Search videos.

    Parameters

    • query: string

      The query to search with

    • Optional options: VideoSearchOptions

      The options of the search

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<VideoSearchResults>

    Search results

Spice Functions

currency

  • currency(from: string, to: string, amount?: number, needleOptions?: NeedleOptions): Promise<CurrencyResult>
  • Get the currency conversion between two currencies. Data provided by XE.

    see

    https://www.xe.com/

    Parameters

    • from: string

      The currency to convert from

    • to: string

      The currency to convert to

    • amount: number = 1

      The amount of currency to convert

    • Optional needleOptions: NeedleOptions

      The options for the HTTP request

    Returns Promise<CurrencyResult>

    The currency result

dictionaryAudio

dictionaryDefinition

dictionaryHyphenation

dictionaryPronunciation

dns

  • Get DNS records of a domain. Data provided by ViewDNS.info.

    see

    https://viewdns.info/

    since

    v2.1.0

    Parameters

    • domain: string
    • recordType: DNSRecordType = ...

      The type of DNS record to retrieve

    • Optional needleOptions: NeedleOptions

      The options for the HTTP request

    Returns Promise<DNSResult>

    The dns result

emojipedia

  • emojipedia(emoji: string, needleOptions?: NeedleOptions): Promise<EmojipediaResult>

expandUrl

  • expandUrl(url: string, needleOptions?: NeedleOptions): Promise<ExpandUrlResult>
  • Expand a shortened link. Data provided by Unshorten.me.

    see

    https://unshorten.me/

    since

    v2.2.0

    Parameters

    • url: string

      The URL to unshorten

    • Optional needleOptions: NeedleOptions

      The options for the HTTP request

    Returns Promise<ExpandUrlResult>

    The expandUrl result

forecast

  • forecast(query: string, locale?: string, needleOptions?: NeedleOptions): Promise<ForecastResult | null>
  • Get the forecast of a location. Returns null if there are no results. Data provided by Dark Sky and other sources.

    see

    https://darksky.net/

    Parameters

    • query: string

      The query to search with

    • locale: string = 'en'

      The locale to give the summaries in

    • Optional needleOptions: NeedleOptions

      The options for the HTTP request

    Returns Promise<ForecastResult | null>

    The forecast result

statista

  • statista(query: string, needleOptions?: NeedleOptions): Promise<StatistaResult>

stocks

  • stocks(symbol: string, needleOptions?: NeedleOptions): Promise<StocksResult>
  • Get the stocks of a symbol. Data provided by Xignite.

    see

    https://www.xignite.com/

    Parameters

    • symbol: string

      What symbol to get stats from

    • Optional needleOptions: NeedleOptions

      The options for the HTTP request

    Returns Promise<StocksResult>

    The stocks result

thesaurus

  • thesaurus(word: string, needleOptions?: NeedleOptions): Promise<ThesaurusResult | null>

time

  • time(query: string, needleOptions?: NeedleOptions): Promise<TimeResult>
  • Search the time of locations with a query. Data provided by TimeAndDate.com.

    see

    https://www.timeanddate.com/

    Parameters

    • query: string

      The query to search with

    • Optional needleOptions: NeedleOptions

      The options of the HTTP request

    Returns Promise<TimeResult>

    The time result

Other Functions

getVQD

  • getVQD(query: string, ia?: string, options?: NeedleOptions): Promise<string>
  • Get the VQD of a search query.

    Parameters

    • query: string

      The query to search

    • ia: string = 'web'

      The type(?) of search

    • Optional options: NeedleOptions

      The options of the HTTP request

    Returns Promise<string>

    The VQD

Legend

  • Property

Generated using TypeDoc