0

I need to routinely call Bing News Search results via its API, checking for fresh stories matching a given search query.

I only want to return stories newly published since the last time I called the API.

For example, an hourly call to the API should constrain the search for stories from between the last hour and now (ie. stories published within the last hour).

Here is documentation for Bing News Search API - https://learn.microsoft.com/en-us/rest/api/cognitiveservices/bing-news-api-v7-reference

It makes clear a parameter, "since", which takes Unix epoch time. I will always be able to programmatically generate the epoch time for the start of the period.

Documentation states:

The Unix epoch time (Unix timestamp) that Bing uses to select the trending topics. Bing returns trending topics that it discovered on or after the specified date and time, not the date the topic was published.

If I want to return stories starting from June 22, epoch time for human GMT time Friday, June 22, 2018 12:39:51 PM is 1529671191.

This should allow me to generate API query URL https://api.cognitive.microsoft.com/bing/v7.0/news/search?q=%22Cardiff%22&since=1529671191000&count=100&sortBy=Date&textDecorations=true&textFormat=HTML

  • q="Cardiff"
  • since=1529671191000
  • count=100 (maximum)
  • sortBy=Date
  • textDecorations=true
  • textFormat=HTML

However, when that call is performed, the longest-ago "datePublished" field for a returned story object is "2018-06-20T23:18:00.0000000Z" (ie. June 20), which is clearly two days before the "since" parameter that I specified.

It's so curious, and frustrating. The alternative constraint parameter "freshness", when specified as "Day", seems to successfully constrain the search period to the last 24 hours. But that is not granular enough. "Since" does not work and does not do anything at all.

Is "since" only intended to be used to return Bing News' "Trending Topics" story lists, and not results of news search queries? The documentation language may be ambiguous.

If this is the case, how can I constrain the start/"since" date for my search through the API, other than with "freshness"?

Robert Andrews
  • 1,209
  • 4
  • 23
  • 47

1 Answers1

0

I think the answer is on your question question:

You say:

However, when that call is performed, the longest-ago "datePublished" field for a returned story object is "2018-06-20T23:18:00.0000000Z" (ie. June 20), which is clearly two days before the "since" parameter that I specified.

But just before, you are quoting this from the documentation:

The Unix epoch time (Unix timestamp) that Bing uses to select the trending topics. Bing returns trending topics that it discovered on or after the specified date and time, not the date the topic was published.

So it has probably been discovered after your since value, you cannot compare with the datePublished field

Nicolas R
  • 13,812
  • 2
  • 28
  • 57
  • Thanks, but I don't think it takes >2/3 days for Bing News to discover stories. I ultimately will want a short window, like "since 15 minutes ago", but I purposefully left the above example longer-ago than that in order to test. Surely that was enough? I'm struggling to understand how to formulate this. Am I missing something? – Robert Andrews Jun 25 '18 at 12:48
  • "Thanks, but I don't think it takes >2/3 days for Bing News to discover stories": in that case, ensure that your question has factual items that can be checked. If it's only based on "I think that", we can't help – Nicolas R Jun 25 '18 at 15:03
  • In case, anyone's been wondering around this questions. It's written in the bing search news api documentation: "datePublished: The date and time that Bing discovered the article. The date is in the format, YYYY-MM-DDTHH:MM:SS." – Aesop Mar 16 '23 at 07:14