/README.markdown

https://github.com/VarioLabs/ddg-api.js · Markdown · 86 lines · 66 code · 20 blank · 0 comment · 0 complexity · fd89151a06b0a6d851bfbb01b3194944 MD5 · raw file

  1. # DuckDuckGo Wrapper for Node.js
  2. A very simple wrapper for the DuckDuckGo API (http://duckduckgo.com/api.html). Just simplifies an edge case error check and presents a simple way to set & reuse options.
  3. Usage:
  4. var ddg = require('ddg-api');
  5. var client = new ddg.SearchClient({useSSL: true});
  6. client.search("Apple Inc.", function(error, response, data) {
  7. if (!error && response.statusCode == 200)
  8. {
  9. console.log(data.Abstract);
  10. } else {
  11. console.log("ERROR! " + error + "/" + response.statusCode);
  12. }
  13. });
  14. ----
  15. ## Supported options:
  16. /*
  17. * output format (json or XML - defaults to json)
  18. * Required
  19. */
  20. format: "json"
  21. /*
  22. * pretty print json output
  23. */
  24. , prettyJson: false
  25. /*
  26. * use SSL
  27. * defaults to false
  28. */
  29. , useSSL: false
  30. /*
  31. * Set strict SSL mode
  32. */
  33. , strictSSL: false
  34. /*
  35. * Base URL for API, includes the question mark
  36. */
  37. , baseUrl: "http://api.duckduckgo.com/?"
  38. /*
  39. * SSL Base URL for API, includes the question mark
  40. */
  41. , sslBaseUrl: "https://api.duckduckgo.com/?"
  42. /*
  43. * Skip redirect for bang commands (defaults to true because
  44. * it doesn't make sense for an API client like this to redirect -
  45. * not really sure it should be an option)
  46. */
  47. , noRedirect: true
  48. /*
  49. * Remove HTML from text
  50. * defaults to false
  51. */
  52. , noHtml: false
  53. /*
  54. * Skip Disambiguation records in the response
  55. * Defaults to false
  56. */
  57. , skipDisambig: false
  58. /*
  59. * User Agent
  60. *
  61. */
  62. , userAgent: "DDG Search Client for Node.js ("+SearchClient.version+")"
  63. ## License
  64. Provided under the The MIT License (MIT)
  65. Copyright (c) 2011 Sujal Shah
  66. See LICENSE for details