---
title: "Wikipedia Search Summary API"
description: "After Random images from wikipedia I made another simple API to get the summary for a search term using PHP. It’s a JSONP."
url: "https://h3manth.com/scribe/wikipedia-search-summary-api/"
canonical_url: "https://h3manth.com/scribe/wikipedia-search-summary-api/"
markdown_url: "https://h3manth.com/scribe/blog/wikipedia-search-summary-api.md"
publishDate: "2011-08-27T00:00:00.000Z"
author: "Hemanth HM"
category: "javascript"
tags: ["javascript","web"]
word_count: 136
reading_time_minutes: 1
x_markdown_tokens: 390
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Wikipedia Search Summary API

> After Random images from wikipedia I made another simple API to get the summary for a search term using PHP. It’s a JSONP.

After [Random images from wikipedia](http://h3manth.com/content/random-images-wikipedia) I made another simple API to get the summary for a search term using PHP.

It's a JSONP API that queries the DNS of wikipedia to fetch the TXT records, which also includes a short URL to the complete corresponding Wikipedia entry. As cross-domain requests are possible with this API, one can easily integrate it to search boxes or widgets.

**Monkey code :**

<?php  
  
// Set headers for JSON  
[header](http://www.php.net/header)('Content-type: application/json');  
  
// This the DNS to query   
$DNS=$_GET['q'].".wp.dg.cx";  
  
// Get the TXT records for the Name server  
$result = dns_get_record($DNS,DNS_TXT);  
  
// Return the JSONP  
print $_GET['callback'].'('.[json_encode](http://www.php.net/json_encode)([array](http://www.php.net/array)("res"=>$result[0]['txt'])).')';  
  
?>  

A simple _$.getJSON()_ can be used to get the _data.res _indeed the famous "callback=?" trick is <3'd by one and all.__

[SAMPLE RESPONSE](http://www.h3manth.com/ws.php?q=linux&callback=?) with callback=?

You might also like [One line GUI wikipedia search](http://www.h3manth.com/content/one-line-search-wiki-linux-gui)
