We recently added more than a dozen Microsoft Azure Cognitive Services to the RapidAPI Marketplace. As with all APIs on the Marketplace, you can connect to all of these with just one account, one API Key, and one SDK. Let’s take a look at what these APIs do, and how you can use them as powerful tools in your next project.
What do the Azure Cognitive Services Do?
There are 4 categories of Azure APIs that are now available on the RapidAPI Marketplace: Vision, Language, Web Search, and Decision. Check out the chart below to learn more about each API.
Vision — Identify and analyze content within images, videos, and digital ink.
- Computer Vision: Analyzes content in images.
- Face: Analyzes faces in images.
Language — Extract meaning from unstructured text.
- Translator Text: Enables you to easily conduct real-time text translation.
- Text Analytics: Enables you to unlock insights from natural language text using sentiment analysis, named entity recognition, language detection, and key phrase extraction in multiple languages.
Web Search — Find what you’re looking for from the world-wide-web.
- Bing News Search: Turns any app into a news search resource.
- Bing Web Search: Enables safe, ad-free, location-aware search for your users, surfacing relevant information from web results, images, local business, news, videos, and visuals.
- Bing AutoSuggest: Helps users complete queries faster by adding intelligent type-ahead capabilities.
- Bing Entity Search: Recognizes and classifies named entities, and finds search results based on them
- Bing Image Search: Turns any app into an image search resource.
- Bing Spell Check: Turns any app into a spell check resource.
- Bing Video Search: Turns any app into a video search resource.
Decision — Make smarter decisions faster.
- Content Moderator: Detects unwanted content.
Beginners Guide to Connecting to Azure APIs with Your RapidAPI Account
To start, make sure you are logged in to your RapidAPI account. If you don’t already have an account on RapidAPI, you can create one for free in just a few minutes.
For this tutorial, we will be using the Bing News Search API to get news for a specified query. However, you can connect to any of the APIs by following the same steps listed below.
Step One: Subscribe to the API’s Pricing Plan.
Once you have selected which API (or APIs) you want to use, subscribe to a pricing plan in order to begin testing and using the API. You can see the available plans on the API’s Pricing Page. Bing News Search has a few options, so make sure you understand exactly what is included when you subscribe.
For this tutorial, the free plan will be enough to get started. You can adjust what plan you are utilizing in the future, as your needs change.
Step Two: Test the API from the Endpoint Page
Once you have subscribed to the API, head over to the Endpoints Page to begin testing and integrating the API into your application.
To start we will test the GET News Search Endpoint. You can test any endpoint by selecting it on the left-hand side, filling out the required parameters, and clicking the “Test Endpoint” button.
The required parameter for the News Search Endpoint is “q” the user’s search query. For our tutorial, we set this to “Giants”
"q": "Giants"
If the test is successful, you will see a green box with a 200 status code on the right. You can also see the full response. This is a good way to make sure the API is functioning as expected and meets the functionality requirements for your application.
You can also see the response from the API, by default we get 10 news articles. Here is a section of the response as an example:
Step Three: Adjust the Parameters as Desired
Now that we know the API is working properly, let’s adjust some optional parameters to see how it affects the response. The Bing News Search API has quite a few optional parameters, but we will specifically be looking at “count” and “freshness” for this tutorial.
“count” is the number of news articles returned in the response, with a default of 10. We will adjust this to 5, but you can pick any number up to 100.
"count": "5",
“freshness” allows you to filter by date and time that Bing discovered the news. You can select day (default), week, month, or remove it from the request. We will pick “week” for our example.
"freshness": "Week",
We can also revisit the required parameter, “q” that we set to “Giants” at the beginning. To make our search more specific, we can use Bing Advanced Operators in the query. Since we were more interested in news about the San Francisco Giants than the New York Giants, let’s specify that the results much come from the San Francisco Chronicle. We can do this by formatting our string like this:
"Giants” site:www.sfchronicle.com
When we click Test Endpoint, you will see the new response now only contains five news results from the SF Chronicle that were discovered in the last week, as we specified in our request.
You can continue adjusting the parameters to refine your results if desired.
Step Four: Integrate the API into Your Application
It is quick and easy to integrate the API into your application using the “Copy Code” button on the right side. You can select from a variety of languages in the dropdown.
You can also copy the snippet we generated below:
var unirest = require("unirest"); var req = unirest("GET", "https://bing-news-search1.p.rapidapi.com/news/search"); req.query({ "count": "5", "freshness": "Week", "textFormat": "Raw", "safeSearch": "Off", "q": "%22Giants%22 site%3Awww.sfchronicle.com" }); req.headers({ "x-rapidapi-host": "bing-news-search1.p.rapidapi.com", "x-rapidapi-key": "YOUR-X-RAPIDAPI-KEY-HERE ", "x-bingapis-sdk": "true" }); req.end(function (res) { if (res.error) throw new Error(res.error); console.log(res.body); });
Note: Be sure to fill in your own API Key if you copy this snippet.
Once you copy and paste the snippet into your application, you will also need to install the proper SDK if you have not done so already. Click “Install SDK” to see the instructions for your chosen language.
If you are having trouble integrating the API into your application, you can also watch our RapidAPI Tutorial to see step by step instructions or check out our docs.
Summary
We are so excited to bring the Microsoft Azure Cognitive Services to our developer community. We believe these APIs are another great tool, and we would love to see what you end up building. If you have any questions or would like to share your project with us, please reach out to support@rapidapi.com, or send us a message on Twitter.
Leave a Reply