Tuesday, August 24, 2021

 Bing Search API

Introduction: This article is a continuation of the series of articles starting with the description of SignalR service. We followed up with a discussion of Azure Gateway service, Azure Private Link, and Azure Private Endpoint and the benefit of diverting traffic to Azure Backbone network. Then we started reviewing a more public internet-facing service such as the Bing API.

Description:

Azure Bing API is developer-friendly and provides a robust way of searching custom and scoped content with the same standard as the public internet. A customized search instance can be created using the Bing custom search portal. Bing Search API maintains an index for the internet using web crawlers.

The Bing Search API is an Azure Resource available via the Azure Marketplace. After logging in to the Azure portal, one can select either the Bing API resource or the Bing Custom Search resource.  The resource represents the service that handles the API requests for Web Search. It is created by specifying a name that contains alphanumeric characters and a hyphen. The subscription, pricing tier, resource group, and location are also required to create the resource. When the resource is provisioned, it can be called with a simple GET method to the https://api.bing.microsoft.com/v7.0/search API and the subscription key specified in the header with key Ocp-Apim-Subscription-Key.  The request headers also include a header for providing continuity of experience and another for user location in location-aware queries. The more information that can be provided to Bing, the better the search experience. The continuity behavior is introduced with the header for X-MSEdge-ClientID and this header is used for both the request and the response. Bing uses this header to provide users with consistent behavior across Bing API calls. New features and improvements are flighted with this header. The same value for this header must be specified in all requests across Bing API calls otherwise they won’t be in the same traffic flight. The clientID also helps with search history as the Bing API can improve query results with history. With the same client ID across multiple requests for the same end-user and device, the API can provide higher click-through rates via better quality of results from the Bing APIs. The only caveat is that this client ID must not be linkable to any authenticated user account information.

The response header includes the market used by the request. This is in the form of <languageCode>-<countryCode> as in en-US. It might be different from the request's mkt query parameter and the value for Accept-Language. BingAPIs-TraceID header holds the ID of the log entry that contains the details of the request.

The query-parameter is merely one parameter at the minimum. This parameter called q is set to the user's query string. The user's query string and all query parameter values must be URL encoded. Additional query parameters are optional and include the following: 1) count and offset to refer to the query results by page, 2) the mkt query parameter which is used to specify the market where the results come from, 3) safe search which is used to specify the user's safe search preference and 4) text decorations and text format which is used to turn on hit highlighting. 

 

No comments:

Post a Comment