PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/share/site/duckduckgo/api.tx

https://github.com/nrw/duckduckgo-publisher
Unknown | 247 lines | 190 code | 57 blank | 0 comment | 0 complexity | 5341197ab1f770eb5b395d482dcd2558 MD5 | raw file
  1. <style type="text/css">
  2. pre {
  3. background-color:#EEE;
  4. font-family:Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
  5. padding:10px;
  6. word-wrap: break-word;
  7. font-size: 10pt;
  8. white-space: pre-wrap; /* css-3 */
  9. white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
  10. white-space: -pre-wrap; /* Opera 4-6 */
  11. white-space: -o-pre-wrap; /* Opera 7 */
  12. margin-top:5px;
  13. }
  14. </style>
  15. <div id="special_page_header"><: l('Instant Answer API') :></div>
  16. <: include "untranslated.tx" :>
  17. <div style="margin-bottom:30px;"></div>
  18. Our Instant Answer API gives you free access to many of our instant answers like:
  19. <a href="http://duckduckgo.com/?q=valley+forge+national+park">topic summaries</a>
  20. (<a href="http://api.duckduckgo.com/?q=valley+forge+national+park&format=json&pretty=1">API example</a>),
  21. <a href="http://duckduckgo.com/?q=simpsons+characters">categories</a>
  22. (<a href="http://api.duckduckgo.com/?q=simpsons+characters&format=json&pretty=1">API example</a>),
  23. <a href="http://duckduckgo.com/?q=apple">disambiguation</a>
  24. (<a href="http://api.duckduckgo.com/?q=apple&format=json&pretty=1">API example</a>),
  25. and
  26. <a href="/bang.html">!bang redirects</a>
  27. (<a href="http://api.duckduckgo.com/?q=!imdb+rushmore&format=json&pretty=1&no_redirect=1">API example</a>).
  28. <div style="margin-bottom:20px;"></div>
  29. This API does not include all of our links, however. That is, it is not a full search results API or a way to get DuckDuckGo results into your applications beyond our instant answers. Because of the way <a href="http://help.duckduckgo.com/customer/portal/articles/216399">we generate our search results</a>, we unfortunately do not have the rights to fully syndicate our results. For the same reason, we cannot allow framing our results without our branding. Please see <a href="http://help.duckduckgo.com/customer/portal/articles/775109">our partnerships page</a> for more info on guidelines and getting in touch with us.
  30. <div style="margin-bottom:20px;"></div>
  31. Our long-term goal is for <a href="https://duckduckgo.com/goodies/">all of our instant answers</a> to be available through this open API. Many of these instant answers are open source via our <a href="http://duckduckhack.com/">DuckDuckHack</a> platform. Using that platform, you can add your own APIs and data sources as well.
  32. <p style="margin-top: 20px;">
  33. Our instant answers come from a variety of sources, including <a href="http://wikipedia.org">Wikipedia</a>, <a href="http://wikia.com/">Wikia</a>, <a href="http://crunchbase.com">Crunchbase</a>, <a href="http://github.com">GitHub</a>, <a href="http://wikihow.com">WikiHow</a>, <a href="http://thefreedictionary.com">The Free Dictionary</a> &ndash; over 100 in total.
  34. <p style="margin-top: 20px;">
  35. This API serves <a href="/traffic.html">over 10,000,000 queries a day</a> for a variety of uses, e.g.:
  36. <ul>
  37. <li>Defining people, places, things, words and concepts, e.g. for side-bars, onMouseover or onHiglight.
  38. <li>Providing direct links to other services (via <a href="/bang.html">!bang syntax</a>).
  39. <li>Listing related topics.
  40. <li>Giving official sites when available.
  41. </ul>
  42. <p style="margin-top: 25px;">
  43. To consume it yourself, you can use one of the language libraries listed below or simply add '&format=json' (or xml if you have a death wish) onto any query URL in the api subdomain, e.g.
  44. <br><a href="http://api.duckduckgo.com/?q=DuckDuckGo&format=json&pretty=1">http://api.duckduckgo.com/?q=DuckDuckGo&format=json</a>
  45. <p style="margin-top: 25px;">
  46. Here are the requirements for use:
  47. <ul>
  48. <li>Attribution in each place you use our API for both us and any underlying source. For the source, you can link to the source's relevant detail page. For us, you can say <a href="https://duckduckgo.com/">Results from DuckDuckGo</a> with our logo (and link to the specific result page).
  49. <li>Non-commercial use unless you get <a href="http://help.duckduckgo.com/customer/portal/articles/775109">email approval from us</a> (though we're generally fine with anything that isn't sketchy).
  50. <li>Use a descriptive <a href="http://help.duckduckgo.com/customer/portal/articles/448610">t parameter</a>, i.e. append &t=nameofapp to your requests.
  51. </ul>
  52. Our overall goal is to get more people using DuckDuckGo, so please keep that in mind as well.
  53. <p style="margin-top: 25px;">
  54. Here are the return fields:
  55. <p style="margin-top: 5px;">
  56. <pre>
  57. Abstract: topic summary (can contain HTML, e.g. italics)
  58. AbstractText: topic summary (with no HTML)
  59. AbstractSource: name of Abstract source
  60. AbstractURL: deep link to expanded topic page in AbstractSource
  61. Image: link to image that goes with Abstract
  62. Heading: name of topic that goes with Abstract
  63. Answer: instant answer
  64. AnswerType: type of Answer, e.g. calc, color, digest, info, ip, iploc, phone, pw, rand, regexp, unicode, upc, or zip (see <a href="http://duckduckgo.com/goodies.html">goodies</a> & <a href="http://duckduckgo.com/tech.html">tech</a> pages for examples).
  65. Definition: dictionary definition (may differ from Abstract)
  66. DefinitionSource: name of Definition source
  67. DefinitionURL: deep link to expanded definition page in DefinitionSource
  68. RelatedTopics: array of internal links to related topics associated with Abstract
  69. Result: HTML link(s) to related topic(s)
  70. FirstURL: first URL in Result
  71. Icon: icon associated with related topic(s)
  72. URL: URL of icon
  73. Height: height of icon (px)
  74. Width: width of icon (px)
  75. Text: text from first URL
  76. Results: array of external links associated with Abstract
  77. Result: HTML link(s) to external site(s)
  78. FirstURL: first URL in Result
  79. Icon: icon associated with FirstURL
  80. URL: URL of icon
  81. Height: height of icon (px)
  82. Width: width of icon (px)
  83. Text: text from FirstURL
  84. Type: response category, i.e. A (article), D (disambiguation), C (category), N (name), E (exclusive), or nothing.
  85. Redirect: !bang redirect URL
  86. </pre>
  87. <p style="margin-top: 20px;">
  88. Here are all the parameters:
  89. <p style="margin-top: 5px;">
  90. <pre>
  91. q: query
  92. format: output format (json or xml)
  93. If format=='json', you can also pass:
  94. callback: function to callback (JSONP format)
  95. pretty: 1 to make JSON look pretty (like JSONView for <a href="https://chrome.google.com/extensions/detail/chklaanhfefbnpoihckbnefhakgolnmc">Chrome</a>/<a href="https://addons.mozilla.org/en-US/firefox/addon/10869/">Firefox</a>)
  96. no_redirect: 1 to skip HTTP redirects (for !bang commands).
  97. no_html: 1 to remove HTML from text, e.g. bold and italics.
  98. skip_disambig: 1 to skip disambiguation (D) Type.
  99. </pre>
  100. <p style="margin-top: 35px;">
  101. <b>Notes</b>
  102. <ul>
  103. <li class="small">As this is an instant answer API, most deep queries (non topic names) will be blank.
  104. <pre>
  105. {
  106. Abstract: ""
  107. AbstractText: ""
  108. AbstractSource: ""
  109. AbstractURL: ""
  110. Image: ""
  111. Heading: ""
  112. Answer: ""
  113. Redirect: ""
  114. AnswerType: ""
  115. Definition: ""
  116. DefinitionSource: ""
  117. DefinitionURL: ""
  118. RelatedTopics: [ ]
  119. Results: [ ]
  120. Type: ""
  121. }
  122. </pre>
  123. <!--
  124. <p style="margin-top: 5px;">
  125. <li class="small">If there is no icon for a given Topic or Result, Icon will be a blank hash, i.e. {}, instead of a hash with every sub-field being an empty string.
  126. //-->
  127. <p style="margin-top: 5px;">
  128. <li class="small">Icons, i.e. the underlying images, may be greater than their specified Width/Height. You should explicitly set them to the specified measurements (if provided).
  129. <p style="margin-top: 5px;">
  130. <li class="small">For disambiguation pages (Type=='D'), RelatedTopics can be grouped into sections. In that case, RelatedTopics is an array of hashes. Each hash has a Name key and a Topics array matching the above RelatedTopics description. If you want to avoid this case altogether, use the disambiguation skip parameter (skip_disambig).
  131. <p style="margin-top: 5px;">
  132. <li class="small">For <a href="/bang.html">!bang commands</a>, the redirect will happen at the HTTP level (since that is fastest), but it will also be returned in the content (for parsing). If you don't want the redirect to happen in the HTTP header, use the no_redirect flag.
  133. <p style="margin-top: 5px;">
  134. <li class="small">Queries can be case sensitive e.g.
  135. <a href="/?q=blackberry">blackberry</a> (<a href="http://api.duckduckgo.com/?q=blackberry&format=json&pretty=1">API example</a>)
  136. vs
  137. <a href="/?q=BlackBerry">BlackBerry</a> (<a href="http://api.duckduckgo.com/?q=BlackBerry&format=json&pretty=1">API example</a>). In the first case (lowercase blackberry) it returns a disambiguation page; in the latter case (MixedCase BlackBerry) it returns info primarily about the device (inferring what you meant from the case).
  138. <p style="margin-top: 5px;">
  139. <li class="small">This API can work over an encrypted (SSL/HTTPS) connection.
  140. </ul>
  141. <p style="margin-top: 35px;">
  142. <b>FAQ</b>
  143. <p style="margin-top: 10px;">
  144. <i>Are there supporting library integrations?</i>
  145. <p style="margin-top: 5px;">
  146. <ul>
  147. <span class="small">
  148. <li>You can consume this API via <a href="http://www.mashape.com/apis/DuckDuckGo%20Zero-click%20Info">Mashape</a>, which provides PHP, Ruby, Python, Objective-C and Java (including Android) libraries. To do so, <a href="http://www.mashape.com/account/request-alpha-invite?apiName=DuckDuckGo%20Zero-click%20Info">sign up</a> (use the code DUCKDUCK) and <a href="http://www.mashape.com/account/login?apiName=DuckDuckGo%20Zero-click%20Info">login</a>.
  149. <li><a href="http://search.cpan.org/perldoc?WWW::DuckDuckGo">Perl module</a> & <a href="http://search.cpan.org/perldoc?duckduckgo">command line app</a> by <a href="http://twitter.com/#!/raudssus">@raudssus</a>.
  150. <li><a href="http://pypi.python.org/pypi/duckduckgo2/0.2">Python library</a> by mikejs.
  151. <li><a href="http://dhruvbird.com/ddb/zc.html">Zero-click jQuery Search Widget</a> by <a href="http://twitter.com/#!/dhruvbird">@dhruvbird</a> that provides info for you in iframe format.
  152. <li><a href="https://github.com/SiegfriedEhret/jddg">jddg jQuery plugin</a> [<a href="http://dev.federalbureauofinhumanity.org/jddg/demo/">demo</a>] by <a href="http://federalbureauofinhumanity.org/">Siegfried Ehret</a>
  153. <li><a href="https://github.com/andrewrjones/ruby-duck-duck-go">Ruby Gem</a> by <a href="http://andrew-jones.com/">Andrew Jones</a>
  154. <li><a href="https://github.com/ajanicij/goduckgo">Go library</a> by <a href="https://github.com/ajanicij">ajanicij</a>
  155. <li><a href="https://github.com/lukewendling/ddg-api">Node.js module</a> by <a href="http://lukewendling.com">Luke Wendling</a>
  156. <li><a href="https://github.com/jawerty/node-ddg">Node.js wrapper</a> by <a href="http://jawerty.github.io/">Jared Wright</a>
  157. <li><a href="https://github.com/timkly/DuckDuckGo.Net">.Net Library</a> by <a href="http://tk.id.au/">Tim Kelly</a>
  158. <li>If you make another supporting library, we'll add it here!
  159. </span>
  160. </ul>
  161. <p style="margin-top: 25px;">
  162. <i>Why is x query blank? Where are all the Web links like on the main site?</i>
  163. <p style="margin-top: 5px;">
  164. <span class="small">This is an Instant Answer API, and not a full results API. However, there are some Web links within it, e.g. official sites. Please see the second paragraph at the top for more info.</span>
  165. <p style="margin-top: 25px;">
  166. <i>Why is my query blank? I see an Instant Answer on the main site!</i>
  167. <p style="margin-top: 5px;">
  168. <span class="small">
  169. Not all of our instant answers are available right now via this API for a variety of reasons, though it is our long term goal to make them so. However, if you would like to see something in particular please <a href="/feedback.html">let us know</a>, and perhaps we can prioritize making it happen.
  170. </span>
  171. <p style="margin-top: 25px;">
  172. <i>Can I use the DuckDuckGo name to help promote what I've developed with the API?</i>
  173. <p style="margin-top: 5px;">
  174. <span class="small">
  175. Yes and no. We do not want to confuse users into thinking that your application was made by us. Please see <a href="http://help.duckduckgo.com/customer/portal/articles/775109">our partnerships page</a> for more info on guidelines and getting in touch with us.
  176. </span>
  177. <p style="margin-top: 25px;">
  178. <i>Is this API open source?</i>
  179. <p style="margin-top: 5px;">
  180. <span class="small">
  181. No, though many of the instant answers it provides are open source via our <a href="http://duckduckhack.com/">DuckDuckHack platform</a>, which is completely open source. For more information on DuckDuckGo open source, please see <a href="http://help.dukgo.com/customer/portal/articles/216390-open-source">this help article</a>.
  182. </span>
  183. <p style="margin-top: 25px;">
  184. <i>Are there technical limits on API use?</i>
  185. <p style="margin-top: 5px;">
  186. <span class="small">
  187. We simply do not have the resources to support high queries per second (QPS) for a single machine. Generally, this isn't a problem because our API is designed to be used client-side by individual users after they take some specific action (like a search or right-click). We also get a lot of botnet attacks. As a result, there is automatic throttling for API requests that will probably not effect you if you use the API in a distributed fashion (i.e. on your application's front-end). For specific situations we also provide higher limits. If you feel you may be in such a situation, please <a href="http://help.dukgo.com/customer/portal/articles/775109-partnerships">reach out</a>. For legal limits, please see above for attribution and other requirements.
  188. </span>
  189. <p style="margin-top: 25px;">
  190. If you have more questions, please <a href="http://help.duckduckgo.com/customer/portal/articles/775109">let us know</a>.