Obučavanje
Put učenja
Microsoft Search fundamentals - Training
Learn about Microsoft Search including where users can search, the answers and results they'll see, and how you can tailor the search experience for your organization.
Ovaj preglednik više nije podržan.
Nadogradite na Microsoft Edge da iskoristite najnovije osobine, sigurnosna ažuriranja i tehničku podršku.
If you’re building a news-only search results page and you want to get news that’s trending on social media, call this API.
Calling the API is easy. If you have your subscription key, just send an HTTP GET request to the following endpoint:
https://api.bing.microsoft.com/v7.0/news/trendingtopics
Here's a cURL example that shows you how to call the endpoint using your subscription key:
curl -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" https://api.bing.microsoft.com/v7.0/news/trendingtopics
Although that's all you need to do to get trending news, Bing suggests that you include a couple of other headers to provide a better search experience for your user. Those headers include:
The more information you can provide Bing, the better the search experience will be for your users. To learn more about these headers, see Request headers.
Here's a cURL example that includes these headers.
curl -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" -H "X-MSEdge-ClientID: 00B4230B74496E7A13CC2C1475056FF4" -H "X-MSEdge-ClientIP: 11.22.33.44" -H "X-Search-Location: lat:55;long:-111;re:22" -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36" https://api.bing.microsoft.com/v7.0/news/trendingtopics?mkt=en-us
Bing returns a couple of headers you should capture.
To learn more about these headers, see Response headers.
Here's a cURL call that returns the response headers. If you want to remove the response data so you can see only the headers, include the -o nul
parameter.
curl -D - -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" https://api.bing.microsoft.com/v7.0/news/trendingtopics?mkt=en-us
The API supports a number of query parameters that you can pass in your request. Here's a list of the ones you're most likely to use.
To learn more about these parameters, see Query parameters.
Here's a cURL example that includes these query parameters.
curl -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" https://api.bing.microsoft.com/v7.0/news/trendingtopics?mkt=en-us&since=1597755615&sortby=date
The following JSON fragment shows what the Trending News response looks like. Use name
and image
to present the list of trending news stories. Be sure to use provider
to attribute the image. To make the name
and/or image
clickable, do one of the following:
webSearchUrl
, which takes the user to Bing's Web search results page.newsSearchUrl
, which takes the user to Bing's News search results page.{
"_type": "TrendingTopics",
"value": [
{
"webSearchUrl": "https://www.bing.com/search?q=Penguins+Australia+New+Zealand&form=TNSA01...",
"name": "Not from Antarctic",
"image": {
"url": "https://www.bing.com/th?id=OPN.RTNews_Gce3fo6Et6sjm7kT0JYV-g&c=14&rs=...",
"provider": [
{
"_type": "Organization",
"name": "© David Merron Photography/Getty Images"
}
]
},
"isBreakingNews": false,
"query": {
"text": "Penguins Australia New Zealand"
},
"newsSearchUrl": "https://www.bing.com/news/search?q=Penguins+Australia+New+Zealand&form=TNSA02..."
},
...
]
}
Bilješka
Because URL formats and parameters are subject to change without notice, use all URLs in Bing search results as-is. You should not take dependencies on the URL format or parameters except where noted.
Obučavanje
Put učenja
Microsoft Search fundamentals - Training
Learn about Microsoft Search including where users can search, the answers and results they'll see, and how you can tailor the search experience for your organization.
Dokumentacija
Get news by news categories - Bing Search Services
Learn how to get news by news category.
Bing News Search API samples - Bing Search Services
Use the Bing News Search API samples to search the web for news.
Search for news with the Bing News Search API - Bing Search Services
Learn how to send search queries for general news, trending topics, and headlines.