For all the APIs we have covered, there are a few similarities. We will cover these now.
It is highly recommended to specify which market you want results for. Searches will typically return results for the local market and language of the user, based on the current location. As you can imagine, this is not always what the user wants. By specifying the market, you can tailor the search results for the user.
How you choose to solve this technically is dependent on the requirements of your application. For a smart-house application, you would probably allow the user to set the market in the settings. For a web application created only for French users in France, you would probably not allow the user to change the market.
Specifying the market is done by adding the mkt
parameter to the GET
request. This should then specify the market code, for example, en-US
for English in the United States.
A subset of the languages supported is English, Spanish, German, Dutch, French, Portuguese, Traditional Chinese, Italian, Russian, and Arabic.
In addition, we can specify a cc
parameter to the GET
request. This specifies a country (typically, the country the user is in). This parameter should be in the form of a two-letter country code, for instance, GB for United Kingdom.
A wide variety of countries can be specified, and the list is continuously subject to change.
Some searches may yield a large number of results. In these cases, you may want to perform pagination. This can be achieved by specifying the count
and offset
parameters in the GET request.
If you want 10 results per page, you would start by setting the count to 10, and the offset to 0 for the first page. When the user navigates to the next page, you would keep the count
at 10, but increase the offset
to 10. For the next page, you would increase the offset
to 20, and so on.
The maximum number of results returned in each query (the count parameter) varies for each API. See the following table for the current maximum count per API:
API |
Maximum search results |
Default search results |
---|---|---|
Bing News Search |
100 |
10 |
Bing Web Search |
50 |
10 |
Bing Image Search |
150 |
35 |
Bing Video Search |
105 |
35 |
We have seen some filters for individual APIs. In addition to these, there are a couple of filters which can be applied to all searches.
The safe search filter can be used to filter search results for adult content. This parameter is added in the request URL.
The safeSearch
parameter can be one of the following values:
Note that, if the IP address of the user indicates a location that requires the Strict safe search, this setting will be ignored. Bing will, in this case, default to the Strict policy.
If the parameter has not been set, it defaults to moderate.
Among all the APIs we have covered, there are a few possible response codes that you may receive for each request. The following table describes all of the possible response codes:
Code |
Description |
---|---|
|
Successful request. |
|
One or more required query parameters are missing, or one of the parameters is invalid. More details are described in the |
|
The provided subscription key is invalid or missing. |
|
Typically returned if the monthly quota is exceeded. Can also be used if the caller does not have permission to access the requested resource. |
|
The HTTP protocol has been used instead of HTTPS, which is the only supported protocol. |
|
The quota per second has been exceeded. |
18.226.251.206