Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple jQuery based sample to show Bing Search v5 API in action
<!DOCTYPE html>
<title>Bing Search v5 - Simple, show fewer results</title>
<script src=""></script>
<script type="text/javascript">
// more info:
var total;
var results = '';
// In this sample, I'm trying to find the pages of my blog that Bing has indexed with the "site:" operator with the "q" parameter
//For more info on the other querystring parameters refer to the documentation -
$(function() {
var params = {
// Request parameters
"q": "",
"count": "50",
"offset": "0",
"mkt": "en-us",
//"safesearch": "Moderate",
url: "" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","abc123"); //replace value with your own key
type: "GET",
// Request body
//data: "{body}",
.done(function(data) {
len = data.webPages.value.length
for (i=0; i<len; i++ )
results += "<p><a href='" + data.webPages.value[i].url + "'>" + data.webPages.value[i].name + "</a>: " + data.webPages.value[i].snippet + "</p>";
.fail(function() {
<div id="content">Fetching...</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment