Skip to content

Commit 0e521c1

Browse files
author
dksimpson
committed
Refresh Bing Entity Search REST API quickstarts
1 parent 7b6291e commit 0e521c1

File tree

6 files changed

+51
-48
lines changed

6 files changed

+51
-48
lines changed

articles/cognitive-services/Bing-Entities-Search/quickstarts/csharp.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using C#
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple C# application sends a news search query to the API, and displays the response. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingEntitySearchv7.cs).
1919

20-
While this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages.
2121

2222

2323
## Prerequisites
@@ -26,18 +26,18 @@ While this application is written in C#, the API is a RESTful Web service compat
2626

2727
- The [Json.NET](https://www.newtonsoft.com/json) framework, available as a NuGet package. To install the NuGet package in Visual Studio:
2828

29-
1. Right click your project in **Solution Explorer**.
29+
1. Right-click your project in **Solution Explorer**.
3030
2. Select **Manage NuGet Packages**.
31-
3. Search for *Newtonsoft.Json* and install the package.
31+
3. Search for and select *Newtonsoft.Json*, and then install the package.
3232

33-
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
33+
- If you're using Linux/MacOS, this application can be run by using [Mono](https://www.mono-project.com/).
3434

3535

3636
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
3737

3838
## Create and initialize a project
3939

40-
1. create a new C# console solution in Visual Studio. Then add the following namespaces into the main code file.
40+
1. Create a new C# console solution in Visual Studio. Then, add the following namespaces into the main code file:
4141

4242
```csharp
4343
using Newtonsoft.Json;
@@ -46,7 +46,7 @@ While this application is written in C#, the API is a RESTful Web service compat
4646
using System.Text;
4747
```
4848

49-
2. Create a new class, and add variables for the API endpoint, your subscription key, and query you want to search. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
49+
2. Create a new class, and add variables for the API endpoint, your subscription key, and the query you want to search. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
5050

5151
```csharp
5252
namespace EntitySearchSample
@@ -71,8 +71,8 @@ While this application is written in C#, the API is a RESTful Web service compat
7171

7272
1. Within the class, create a function called `Search()`. Create a new `HttpClient` object, and add your subscription key to the `Ocp-Apim-Subscription-Key` header.
7373

74-
1. Construct the URI for your request by combining the host and path. Then add your market, and URL-encode your query.
75-
2. Await `client.GetAsync()` to get a HTTP response, and then store the json response by awaiting `ReadAsStringAsync()`.
74+
1. Construct the URI for your request by combining the host and path. Then, add your market and URL-encode your query.
75+
2. Await `client.GetAsync()` to get an HTTP response, and then store the JSON response by awaiting `ReadAsStringAsync()`.
7676
3. Format the JSON string with `JsonConvert.DeserializeObject()` and print it to the console.
7777

7878
```csharp

articles/cognitive-services/Bing-Entities-Search/quickstarts/java.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515
# Quickstart: Send a search request to the Bing Entity Search REST API using Java
1616

1717
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple Java application sends a news search query to the API, and displays the response.
1818

19-
While this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
19+
Although this application is written in Java, the API is a RESTful Web service compatible with most programming languages.
2020

2121
## Prerequisites
2222

23-
* The [Java Development Kit(JDK)](https://www.oracle.com/technetwork/java/javase/downloads/)
24-
* The [Gson library](https://github.com/google/gson)
23+
* The [Java Development Kit (JDK)](https://www.oracle.com/technetwork/java/javase/downloads/).
24+
* The [Gson library](https://github.com/google/gson).
2525

2626

2727
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
2828

2929
## Create and initialize a project
3030

31-
1. Create a new Java project in your favorite IDE or editor, and import the following libraries.
31+
1. Create a new Java project in your favorite IDE or editor, and import the following libraries:
3232

3333
```java
3434
import java.io.*;
@@ -45,7 +45,7 @@ While this application is written in Java, the API is a RESTful Web service comp
4545
import com.google.gson.JsonParser;
4646
```
4747

48-
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
48+
2. In a new class, create variables for the API endpoint, your subscription key, and a search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4949

5050
```java
5151
public class EntitySearch {
@@ -63,7 +63,7 @@ While this application is written in Java, the API is a RESTful Web service comp
6363

6464
## Construct a search request string
6565

66-
1. Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`. Add your market to the string with `?mkt=`.
66+
1. Create a function called `search()` that returns a JSON `String`. url-encode your search query, and add it to a parameters string with `&q=`. Add your market to the parameter string with `?mkt=`.
6767

6868
2. Create a URL object with your host, path, and parameters strings.
6969

@@ -99,7 +99,7 @@ While this application is written in Java, the API is a RESTful Web service comp
9999
//...
100100
```
101101

102-
3. Create a `String` object to store the response from the `BufferedReader`. Iterate through it, and append each line to the string. Then close the reader, and return the response.
102+
3. Create a `String` object to store the response from the `BufferedReader`. Iterate through it, and append each line to the string. Then, close the reader and return the response.
103103

104104
```java
105105
String line;
@@ -114,9 +114,9 @@ While this application is written in Java, the API is a RESTful Web service comp
114114

115115
## Format the JSON response
116116

117-
1. Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, and call `parse()` on the json text, and store it as a JSON object.
117+
1. Create a new function called `prettify` to format the JSON response. Create a new `JsonParser`, call `parse()` on the JSON text, and then store it as a JSON object.
118118

119-
2. Use the Gson library to create a new `GsonBuilder()`, and use `setPrettyPrinting().create()` to format the json. Then return it.
119+
2. Use the Gson library to create a new `GsonBuilder()`, use `setPrettyPrinting().create()` to format the JSON, and then return it.
120120

121121
```java
122122
//...

articles/cognitive-services/Bing-Entities-Search/quickstarts/nodejs.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using Node.js
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple JavaScript application sends a news search query to the API, and displays the response. The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingEntitySearchv7.js).
1919

20-
While this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

2424
* The latest version of [Node.js](https://nodejs.org/en/download/).
2525

26-
* The [JavaScript Request Library](https://github.com/request/request)
26+
* The [JavaScript Request Library](https://github.com/request/request).
2727

2828
[!INCLUDE [cognitive-services-bing-news-search-signup-requirements](../../../../includes/cognitive-services-bing-entity-search-signup-requirements.md)]
2929

3030
## Create and initialize the application
3131

32-
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and https requirements.
32+
1. Create a new JavaScript file in your favorite IDE or editor, and set the strictness and HTTPS requirements.
3333

3434
```javaScript
3535
'use strict';
3636
let https = require ('https');
3737
```
3838

39-
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
39+
2. Create variables for the API endpoint, your subscription key, and search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4040

4141
```javascript
4242
let subscriptionKey = 'ENTER YOUR KEY HERE';
@@ -63,14 +63,14 @@ While this application is written in JavaScript, the API is a RESTful Web servic
6363
};
6464
```
6565

66-
2. Store the body of the response when the **data** flag is called
66+
2. Store the body of the response when the `data` flag is called.
6767
```javascript
6868
response.on('data', function (d) {
6969
body += d;
7070
});
7171
```
7272

73-
3. When an **end** flag is signaled, parse the JSON, and print it.
73+
3. When an `end` flag is signaled, parse the JSON, and print it.
7474

7575
```javascript
7676
response.on ('end', function () {
@@ -81,10 +81,10 @@ While this application is written in JavaScript, the API is a RESTful Web servic
8181

8282
## Send a request
8383

84-
1. Create a function called `Search` to send a search request. In it, perform the following steps.
84+
1. Create a function called `Search` to send a search request. In it, perform the following steps:
8585

86-
1. Create a JSON object containing your request parameters: use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
87-
2. Use `https.request()` to send the request with the response handler created earlier, and your search parameters.
86+
1. Create a JSON object containing your request parameters. Use `Get` for the method, and add your host and path information. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
87+
2. Use `https.request()` to send the request with the response handler created previously, and your search parameters.
8888

8989
```javascript
9090
let Search = function () {

articles/cognitive-services/Bing-Entities-Search/quickstarts/php.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using PHP
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple PHP application sends a news search query to the API, and displays the response.
1919

20-
While this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in PHP, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

@@ -27,12 +27,12 @@ While this application is written in PHP, the API is a RESTful Web service compa
2727

2828
## Search entities
2929

30-
To run this application, follow these steps.
30+
To run this application, follow these steps:
3131

3232
1. Create a new PHP project in your favorite IDE.
3333
2. Add the code provided below.
3434
3. Replace the `key` value with an access key valid for your subscription.
35-
4. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
35+
4. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
3636
5. Run the program.
3737

3838
```php
@@ -79,7 +79,7 @@ echo json_encode (json_decode ($result), JSON_PRETTY_PRINT);
7979
?>
8080
```
8181

82-
**Response**
82+
## Example JSON response
8383

8484
A successful response is returned in JSON, as shown in the following example:
8585

articles/cognitive-services/Bing-Entities-Search/quickstarts/python.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Send a search request to the Bing Entity Search REST API using Python
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple Python application sends a news search query to the API, and displays the response. The source code for this sample is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/python/Search/BingEntitySearchv7.py).
1919

20-
While this application is written in Python, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in Python, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

@@ -27,7 +27,7 @@ While this application is written in Python, the API is a RESTful Web service co
2727

2828
## Create and initialize the application
2929

30-
1. Create a new Python file in your favorite IDE or editor, and add the following imports. Create variables for your subscription key, endpoint, market, and a search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
30+
1. Create a new Python file in your favorite IDE or editor, and add the following imports. Create variables for your subscription key, endpoint, market, and search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
3131

3232
```python
3333
import http.client, urllib.parse
@@ -40,18 +40,21 @@ While this application is written in Python, the API is a RESTful Web service co
4040
query = 'italian restaurants near me'
4141
```
4242

43-
2. Create a request url by appending your market variable to the `?mkt=` parameter. Url-encode your query and appending it to the `&q=` parameter.
43+
2. Create a request url by appending your market variable to the `?mkt=` parameter. Url-encode your query and append it to the `&q=` parameter.
4444

4545
```python
4646
params = '?mkt=' + mkt + '&q=' + urllib.parse.quote (query)
4747
```
4848

4949
## Send a request and get a response
5050

51-
1. Create a function called `get_suggestions()`. Then perform the following steps.
52-
1. Add your subscription key to a dictionary with `Ocp-Apim-Subscription-Key` as a key.
53-
2. Use `http.client.HTTPSConnection()` to create a HTTPS client object. Send a `GET` request using `request()` with your path and parameters, and header information.
54-
3. Store the response with `getresponse()`, and return `response.read()`.
51+
1. Create a function called `get_suggestions()`.
52+
53+
2. In this function, add your subscription key to a dictionary with `Ocp-Apim-Subscription-Key` as a key.
54+
55+
3. Use `http.client.HTTPSConnection()` to create an HTTPS client object. Send a `GET` request using `request()` with your path and parameters, and header information.
56+
57+
4. Store the response with `getresponse()`, and return `response.read()`.
5558

5659
```python
5760
def get_suggestions ():
@@ -62,7 +65,7 @@ While this application is written in Python, the API is a RESTful Web service co
6265
return response.read()
6366
```
6467

65-
2. Call `get_suggestions()`, and print the json response.
68+
5. Call `get_suggestions()`, and print the JSON response.
6669

6770
```python
6871
result = get_suggestions ()

articles/cognitive-services/Bing-Entities-Search/quickstarts/ruby.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-entity-search
1111
ms.topic: quickstart
12-
ms.date: 12/11/2019
12+
ms.date: 05/08/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart for Bing Entity Search API with Ruby
1717

1818
Use this quickstart to make your first call to the Bing Entity Search API and view the JSON response. This simple Ruby application sends a news search query to the API, and displays the response. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/ruby/Search/BingEntitySearchv7.rb).
1919

20-
While this application is written in Ruby, the API is a RESTful Web service compatible with most programming languages.
20+
Although this application is written in Ruby, the API is a RESTful Web service compatible with most programming languages.
2121

2222
## Prerequisites
2323

@@ -27,15 +27,15 @@ While this application is written in Ruby, the API is a RESTful Web service comp
2727

2828
## Create and initialize the application
2929

30-
1. In your favorite IDE or code editor, create a news Ruby file and import the following packages.
30+
1. In your favorite IDE or code editor, create a news Ruby file and import the following packages:
3131

3232
```ruby
3333
require 'net/https'
3434
require 'cgi'
3535
require 'json'
3636
```
3737

38-
2. Create variables for your API endpoint, News search URL, your subscription key, and a search query. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
38+
2. Create variables for your API endpoint, News search URL, your subscription key, and search query. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
3939

4040
```ruby
4141
host = 'https://api.cognitive.microsoft.com'
@@ -61,7 +61,7 @@ While this application is written in Ruby, the API is a RESTful Web service comp
6161
request['Ocp-Apim-Subscription-Key'] = subscriptionKey
6262
```
6363

64-
3. Send the request, and print the response
64+
3. Send the request, and print the response.
6565

6666
```ruby
6767
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|

0 commit comments

Comments
 (0)