Bing Service

Warning

The Bing Service is no longer available in the Windows Community Toolkit. Please use the Cognitive Services SDKs.

The Bing Service allows you to retrieve Bing results. Bing can return web and news results in your language, images, and videos for many countries/regions around the world.

Set up Bing API

Note

The current version does not require the API key and is using the rate limited public access point. The ability to specify your own key to remove the rate limits is on our backlog for a future release.

Signup for API Access using your Microsoft account. There is a free trial option for all of the Bing services (fully functional, just with API rate limits or capacity limits).

Choose the Bing Search - Free option. After selecting this and agreeing to the terms of service you will be issued two keys that are limited to 5,000 queries per month.

Syntax

using Microsoft.Toolkit.Services.Bing;

var searchConfig = new BingSearchConfig
{
    Country = BingCountry.UnitedStates,
    Language = BingLanguage.English,
    Query = SearchText.Text,
    QueryType = BingQueryType.Search
};

ListView.ItemsSource = await BingService.Instance.RequestAsync(searchConfig, 50);
Imports using Microsoft.Toolkit.Services.Bing

Dim searchConfig = New BingSearchConfig With {
    .Country = BingCountry.UnitedStates,
    .Language = BingLanguage.English,
    .Query = SearchText.Text,
    .QueryType = BingQueryType.Search
}
ListView.ItemsSource = Await BingService.Instance.RequestAsync(searchConfig, 50)

BingDataProvider Class

BingDataProvider is a Data Provider for connecting to Bing service

Methods

Methods Return Type Description
GetDataAsync(BingSearchConfig, Int32, Int32, IParser) Task<IEnumerable<TSchema>> Wrapper around REST API for making data request
GetDefaultParser(BingSearchConfig) IParser<BingResult> Returns parser implementation for specified configuration

BingParser Class

BingParser parse Bing results into strong type

Methods

Methods Return Type Description
Parse(String) IEnumerable<BingResult> Take string data and parse into strong data type

BingResult Class

BingResult is a implementation of the Bing result class.

Properties

Property Type Description
InternalID string Gets or sets identifier for strong typed record
Link string Description
Published DateTime Description
Summary string Description
Title string Gets or sets title of the search result

BingSearchConfig Class

BingSearchConfig configures the search query

Properties

Property Type Description
Country BingCountry Description
Language BingLanguage Gets or sets search query language
Query string Gets or sets search query
QueryType BingQueryType Gets or sets search query type

BingService Class

BingService Class for connecting to Bing

Properties

Property Type Description
Instance BingService Gets public singleton property
Provider BingDataProvider Gets a reference to an instance of the underlying data provider

Methods

Methods Return Type Description
GetPagedItemsAsync(Int32, Int32, CancellationToken) Task<IEnumerable<BingResult>> Retrieves items based on pageIndex and pageSize arguments
RequestAsync(BingSearchConfig, Int32, Int32) Task<List<BingResult>> Request list data from service provider based upon a given config / query

Sample Code

Bing Service Sample Page Source. You can see this in action in Windows Community Toolkit Sample App.

Requirements

Device family Universal, 10.0.15063.0 or higher
Namespace Microsoft.Toolkit.Services
NuGet package Microsoft.Toolkit.Services