Knowledge graph api: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
Line 37: Line 37:
(skip)
(skip)
</pre>
</pre>
 
To check the API result, open the [https://api.duckduckgo.com/?q=Keira%20Christina%20Knightley&format=json&pretty=1 URL] directly.
|}
|}



Revision as of 20:25, 12 April 2025

List of Knowledge graph API

List of Knowledge graph API

Understanding the DuckDuckGo Instant Answers API

API Endpoint Structure https://api.duckduckgo.com/?format=<FORMAT>&q=<QUERY>

Where:

  • <FORMAT> specifies the response format (e.g., json)
  • <QUERY> is your URL-encoded search term (e.g., Keira Christina Knightley)

Example: https://api.duckduckgo.com/?format=json&q=who%20is%20girl%20friend%20of%20Simba

Demonstration search term: "Keira Christina Knightley"

  • Web Search Experience: When visiting the DuckDuckGo search page, users see an information card with text like: "Keira Christina Knightley OBE is an English actress. Known for her work in independent films and blockbusters, particularly period dramas..."
  • API Integration: This same biographical information can be programmatically accessed via the Instant Answers API in the "AbstractText" or "Abstract" field of the JSON response.
Example output of DuckDuckGo Instant Answers API (click to show)
{
   "Abstract" : "Keira Christina Knightley OBE is an English actress. Known for her work in independent films and blockbusters, particularly period dramas, she has received numerous accolades, including nominations for two Academy Awards, two British Academy Film Awards, four Golden Globes, and a Laurence Olivier Award. In 2018, she was appointed an OBE at Buckingham Palace for services to drama and charity. Born in London to actors Will Knightley and Sharman Macdonald, Knightley obtained an agent at age six and initially worked in commercials and television films. Following a minor role as Sab\u00e9 in Star Wars: Episode I \u2013 The Phantom Menace, her breakthrough came when she played a tomboy footballer in Bend It Like Beckham and co-starred in Love Actually. She achieved global recognition for playing Elizabeth Swann in the Pirates of the Caribbean film series. For her portrayal of Elizabeth Bennet in Pride & Prejudice, Knightley was nominated for the Academy Award for Best Actress.",
   "AbstractSource" : "Wikipedia",
   "AbstractText" : "Keira Christina Knightley OBE is an English actress. Known for her work in independent films and blockbusters, particularly period dramas, she has received numerous accolades, including nominations for two Academy Awards, two British Academy Film Awards, four Golden Globes, and a Laurence Olivier Award. In 2018, she was appointed an OBE at Buckingham Palace for services to drama and charity. Born in London to actors Will Knightley and Sharman Macdonald, Knightley obtained an agent at age six and initially worked in commercials and television films. Following a minor role as Sab\u00e9 in Star Wars: Episode I \u2013 The Phantom Menace, her breakthrough came when she played a tomboy footballer in Bend It Like Beckham and co-starred in Love Actually. She achieved global recognition for playing Elizabeth Swann in the Pirates of the Caribbean film series. For her portrayal of Elizabeth Bennet in Pride & Prejudice, Knightley was nominated for the Academy Award for Best Actress.",
   "AbstractURL" : "https://en.wikipedia.org/wiki/Keira_Knightley",
(skip)

To check the API result, open the URL directly.

Known Limitation Icon_exclaim.gif: There's currently a discrepancy between web search results and API responses for certain queries. For instance, searching for "height of eiffel tower" produces different results depending on whether you use the web interface or the API endpoint.

References