Bing Search API with NodeJS

Bing provides a search API by which you can use the power of bing search in your own application. The base URL for the search API is:

https://api.cognitive.microsoft.com/bing/v7.0/search

The code to integrate the API using Express and Node JS is:




var express = require('express'); var path = require('path'); var app = express(); var request = require('request'); // The main search function var bing_web_search = function (search, callback) { console.log('Searching the Web for: ' + search); var options = { method: 'GET', url: 'https://api.cognitive.microsoft.com/bing/v7.0/search', qs: { q: search }, headers: { 'ocp-apim-subscription-key': '<YOUR_SUBSCRIPTION_API_KEY>' } }; request(options, function (error, response, body) { callback(error, body); }); }; app.get('/', function (req, res) { bing_web_search('<YOUR_SEARCH_QUERY>', function(error, body) { if (!error) { res.send(body); } else { throw new Error(error); } }); }); app.listen(3000, function () { console.log('Example app listening on port 3000!'); });
Code language: JavaScript (javascript)

The API Subscription Key can be created at the website:

https://azure.microsoft.com/en-in/services/cognitive-services/bing-web-search-api/

If you want more results, then you can use pagination by adding two query params:
1. count: specifies the number of results to return in the response
2. offset: specifies the number of results to skip

Recent Post

  • Federated vs Centralized Learning: The Battle for Privacy, Efficiency, and Scalability in AI

    The ever-expanding field of Artificial Intelligence (AI) and Machine Learning (ML) relies heavily on data to train models. Traditionally, this data is centralized, aggregated, and processed in one location. However, with the emergence of privacy concerns, the need for decentralized systems has grown significantly. This is where Federated Learning (FL) steps in as a compelling […]

  • Federated Learning’s Growing Role in Natural Language Processing (NLP)

    Federated learning is gaining traction in one of the most exciting areas: Natural Language Processing (NLP). Predictive text models on your phone and virtual assistants like Google Assistant and Siri constantly learn from how you interact with them. Traditionally, your interactions (i.e., your text messages or voice commands) would need to be sent back to […]

  • What is Knowledge Distillation? Simplifying Complex Models for Faster Inference

    As AI models grow increasingly complex, deploying them in real-time applications becomes challenging due to their computational demands. Knowledge Distillation (KD) offers a solution by transferring knowledge from a large, complex model (the “teacher”) to a smaller, more efficient model (the “student”). This technique allows for significant reductions in model size and computational load without […]

  • Priority Queue in Data Structures: Characteristics, Types, and C Implementation Guide

    In the realm of data structures, a priority queue stands as an advanced extension of the conventional queue. It is an abstract data type that holds a collection of items, each with an associated priority. Unlike a regular queue that dequeues elements in the order of their insertion (following the first-in, first-out principle), a priority […]

  • SRE vs. DevOps: Key Differences and How They Work Together

    In the evolving landscape of software development, businesses are increasingly focusing on speed, reliability, and efficiency. Two methodologies, Site Reliability Engineering (SRE) and DevOps, have gained prominence for their ability to accelerate product releases while improving system stability. While both methodologies share common goals, they differ in focus, responsibilities, and execution. Rather than being seen […]

  • Moving Beyond Traditional Chatbots: Autonomous Agents Redefining Business Operations

    What if your business could operate on autopilot, with AI systems making crucial decisions and managing tasks in real time? Imagine autonomous agents—advanced AI systems capable of making decisions and performing tasks without constant human oversight—transforming your operations. From streamlining workflows to performing seamless customer interactions, these smart agents promise to redefine efficiency and innovation.  […]

Click to Copy