How to Use Bing API News to Get the Latest News from Around the World
Hi Online Friends,
If you are looking for a way to get the latest news from around the world, you might want to check out Bing API News. Bing API News is a service that allows you to search for news articles with Bing News Search API v7. You can get comprehensive results that include details like authoritative image of the news article, related news and categories, provider info, article URL, and date added. You can also discover new sorting and filtering options that simplify finding specific results in trending news topics.
In this article, I will show you how to use Bing API News to create a news search experience in any application or website. I have experience around "bing api news" and I will share with you some tips and tricks to make the most of this service. Whether you want to get general news, news by category, or today's trending news stories, Bing API News can help you find what you are looking for.
What is Bing API News?
Bing API News is a service that lets you use Bing News Search API v7 to search the web for news articles with your own app or website. Bing News Search API v7 is a cognitive service that provides a similar experience to bing.com/news, letting you send search queries and receive relevant news articles.
Bing API News has several features for intelligent and focused news retrieval on the web. You can get general news stories based on your search query, or get top news articles from different categories if your query is empty. You can also get news stories that are trending on social networks, or search for news in specific categories like business, sports, or entertainment. You can also use various parameters like market, SafeSearch, freshness to refine your news search query.
How to Get Started with Bing API News?
To get started with Bing API News, you need to pick the subscription you want from Bing API Pricing. After getting your subscription key, you are all set to make your first call. You can easily call the API by sending a native HTTP GET request or by using the News Search SDK. For examples to help you get up and running quickly for either option, see Quickstarts.
The basic syntax of the HTTP GET request is as follows:
https://api.bing.microsoft.com/v7.0/news/search?q={query}&mkt={market}&count={count}&offset={offset}&category={category}&originalImg={originalImg}&safeSearch={safeSearch}&setLang={setLang}&textFormat={textFormat}
The query parameter is required and specifies the user's search query. The other parameters are optional and allow you to customize your request. For example, you can specify the market parameter to get results from a specific country or region, or the category parameter to get results from a specific news category.
How to Use Bing API News in Your App or Website?
Once you have your subscription key and know how to make a call to the API, you can use Bing API News in your app or website to create a news search experience for your users. You can use any programming language or framework that supports HTTP requests to integrate Bing API News into your app or website.
For example, if you are using JavaScript, you can use the fetch() method to send an HTTP GET request to the API endpoint and get a JSON response with the news articles. You can then parse the JSON response and display the results in your app or website using HTML and CSS.
Here is a simple example of how to use Bing API News in JavaScript:
// Replace {subscriptionKey} with your subscription keyconst subscriptionKey = '{subscriptionKey}';// Replace {query} with your search queryconst query = '{query}';// Replace {market} with your market codeconst market = '{market}';// Set other parameters as neededconst count = 10;const offset = 0;const category = '';const originalImg = false;const safeSearch = 'Moderate';const setLang = '';const textFormat = 'Raw';// Construct the request URLconst url = `https://api.bing.microsoft.com/v7.0/news/search?q=${query}&mkt=${market}&count=${count}&offset=${offset}&category=${category}&originalImg=${originalImg}&safeSearch=${safeSearch}&setLang=${setLang}&textFormat=${textFormat}`;// Send the request and get the responsefetch(url, { headers: { 'Ocp-Apim-Subscription-Key': subscriptionKey }}).then(response => response.json()).then(data => { // Display the results in your app or website console.log(data);}).catch(error => { // Handle errors console.error(error);});
How to Monitor and Analyze Your Bing API News Usage?
Bing API News also provides API metrics, which you can use to inform your strategic decisions. You can quickly retrieve statistics such as your top queries, call volume, market distribution, response code summary, and many more. You can access these metrics from the Bing Statistics add-in in the Azure portal.
To use the Bing Statistics add-in, you need to enable it in your Bing Search resource in the Azure portal. You can then view the metrics in the Overview or Analytics tabs of your resource. You can also export the metrics to a CSV file or use Power BI to create custom reports and dashboards.
How to Find News by Category with Bing API News?
One of the features of Bing API News is that you can search for news in specific news categories like business, sports, or entertainment. This can help you narrow down your search results and find news that are relevant to your interests or needs.
To find news by category with Bing API News, you need to use the category parameter in your HTTP GET request. The category parameter accepts one of the following values:
- Business
- Entertainment
- Health
- Politics
- ScienceAndTechnology
- Sports
- US/UK/World (depending on the market)
For example, if you want to find news articles about sports in the US market, you can use the following request URL:
https://api.bing.microsoft.com/v7.0/news/search?q=&mkt=en-US&category=Sports
The response will include news articles that belong to the sports category in the US market. You can then display the results in your app or website as you wish.
How to Find Trending News Stories with Bing API News?
Another feature of Bing API News is that you can get news stories that are trending on social networks. This can help you stay updated with the latest and most popular news topics from around the world.
To find trending news stories with Bing API News, you need to use a different endpoint than the one for general news search. The endpoint for trending news stories is as follows:
https://api.bing.microsoft.com/v7.0/news/trendingtopics
You can also use some optional parameters like market, SafeSearch, setLang, and textFormat to customize your request. For example, if you want to get trending news topics in the UK market with moderate safe search and raw text format, you can use the following request URL:
https://api.bing.microsoft.com/v7.0/news/trendingtopics?mkt=en-GB&safeSearch=Moderate&setLang=en&textFormat=Raw
The response will include a list of trending news topics with their names, images, web URLs, and query texts. You can then display the results in your app or website as you wish.
How to Create a Table Breakdown Related to Bing API News?
If you want to create a table breakdown related to Bing API News, you can use HTML table tags to format your data in a structured way. HTML tables allow you to organize your data into rows and columns with headers and captions.
For example, if you want to create a table breakdown that compares the features and prices of different Bing API subscriptions, you can use the following HTML code:
You can see the result of the HTML code in the following table:
Subscription | Free Trial | S1 Tier | S2 Tier | S3 Tier | S4 Tier | S5 Tier | S6 Tier |
---|---|---|---|---|---|---|---|
Price per month | $0 | $4 | $40 | $200 | $1,000 | $4,000 | $10,000 |
Transactions per month | 1,000 | 20,000 | 100,000 | 500,000 | 2.5 million | 10 million | 25 million |
Transactions per second | 3 | 3 | 5 | 10 | 15 | 30 | 50 |
Features | All features except statistics add-in and custom search instance management API. | All features. | All features. | All features. | All features. | All features. | All features. |
FAQs about Bing API News
What are the benefits of using Bing API News?
Some of the benefits of using Bing API News are:
- You can get comprehensive and relevant news results from the web with Bing News Search API v7.
- You can discover new sorting and filtering options that simplify finding specific results in trending news topics.
- You can customize your news search experience with various parameters like market, SafeSearch, freshness, and category.
- You can access API metrics to inform your strategic decisions with the Bing Statistics add-in.
- You can integrate Bing API News into your app or website with any programming language or framework that supports HTTP requests.
How much does Bing API News cost?
Bing API News has different pricing tiers depending on your usage and needs. You can start with a free trial that allows you to make up to 1,000 transactions per month. After that, you can choose from six subscription tiers that range from $4 to $10,000 per month. Each subscription tier has a different limit on the number of transactions per month and per second, as well as different features. For more details, see Bing API Pricing.
How can I get a subscription key for Bing API News?
To get a subscription key for Bing API News, you need to create a Bing Search resource in the Azure portal. You can then select the subscription tier you want and get your subscription key from the Keys and Endpoint tab of your resource. For more details, see How to buy.
How can I use the News Search SDK for Bing API News?
The News Search SDK is a library that simplifies calling the Bing News Search API v7. It is available for several programming languages like C#, Java, Python, Ruby, and Node.js. To use the News Search SDK, you need to install it in your project and import it in your code. You can then create a client object with your subscription key and use its methods to make requests to the API. For more details, see Quickstarts.
What are the use and display requirements for Bing API News?
Bing API News has some use and display requirements that you need to follow when using the service. Some of these requirements are:
- You must use Bing API News only as a result of a direct user query or search, or as a result of an action within an app or experience that logically can be interpreted as a user’s search request.
- You must display the news results in a way that does not suggest that Microsoft is endorsing or sponsoring your app or website, or the content of your app or website.
- You must display the provider name and logo for each news article, as well as a link to the original article URL.
- You must not modify, filter, reorder, or aggregate the news results in any way that alters their meaning or relevance.
- You must not use Bing API News for any unlawful, infringing, or abusive purposes.
For more details, see Use and display requirements.
Conclusion
Bing API News is a service that lets you search for news articles with Bing News Search API v7. You can get comprehensive and relevant news results from the web with various sorting and filtering options. You can also integrate Bing API News into your app or website with any programming language or framework that supports HTTP requests. You can also access API metrics to inform your strategic decisions with the Bing Statistics add-in.
If you want to learn more about Bing API News, you can check out the following resources:
- Bing News Search API | Microsoft Bing
- What is the Bing News Search API? - Bing Search Services | Microsoft Learn
- What is the Bing News Search API? - Azure AI services | Microsoft Learn
- Search for news with the Bing News Search API - Bing Search Services | Microsoft Learn
I hope you found this article helpful and informative. If you have any questions or feedback, please feel free to leave a comment below. Thank you for reading and happy searching!
Subscription | Free Trial | S1 Tier | S2 Tier | S3 Tier | S4 Tier | S5 Tier | S6 Tier |
---|---|---|---|---|---|---|---|
Price per month | $0 | $4 | $40 | $200 | $1,000 | $4,000 | $10,000 |
Transactions per month | 1,000 | 20,000 | 100,000 | 500,000 | 2.5 million | 10 million | 25 million |
Transactions per second | 3 | 3 | 5 | 10 | 15 | 30 | 50 |
Features | All features except statistics add-in and custom search instance management API. | All features. | All features. | All features. | All features. | All features. | All features. |
Post a Comment for "How to Use Bing API News to Get the Latest News from Around the World"