简体   繁体   中英

bing news search API

How does the "freshness" parameter of the Bing news search API work?

I am writng a program to call the Bing news search API. I set the "freshness" parameter to be "Month". Yet, Bing returned content that can be as old as 6 months ago. How did I find out? I use the offset parameter to retrieve the last new pages of the returned result and found out that they are can be as old as 6 months (some even 2 years odl). Clarly, this result is contradict to the fresness parameter that I put in. Can anyone shed some light on this? Many thanks,

The following is the code snippet: Basically, I set the freshness to be Month (freshness=Month) and sort the output by day (sortBy=Day).

   let bing_news_search = function (search) {
console.log('Searching news for: ' + term);
let request_params = {
    method: 'GET',
    hostname: host,
    path: path + '?q=' + encodeURIComponent('Microsoft') +'&count=100'+'&freshness=Month'+'&sortBY=Date'+'&offset=4979900',
    headers: {
        'Ocp-Apim-Subscription-Key': subscriptionKey,
    } 

Moving this to the Answer as verified in comments:

The issue is that the &count is set to 100. The current limit is 50. Once setting this number correctly the API will work as expected.

So it will look like so:

 let bing_news_search = function (search) {
console.log('Searching news for: ' + term);
let request_params = {
    method: 'GET',
    hostname: host,
    path: path + '?q=' + encodeURIComponent('Microsoft') +'&count=50'+'&freshness=Month'+'&sortBY=Date'+'&offset=4979900',
    headers: {
        'Ocp-Apim-Subscription-Key': subscriptionKey,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM