ballerinax/bing.autosuggest Ballerina library

1.5.1

Overview

This is a generated connector for Bing Autosuggest API v1 OpenAPI specification. The Autosuggest API lets partners send a partial search query to Bing and get back a list of suggested queries that other users have searched on. In addition to including searches that other users have made, the list may include suggestions based on user intent. For example, if the query string is weather in Lo, the list will include relevant weather suggestions.

This module supports Bing Autosuggest API v1.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

Quickstart

To use the Bing Autosuggest connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/bing.autosuggest module into the Ballerina project.

Copy
import ballerinax/bing.autosuggest;

Step 2: Create a new connector instance

You can now make the connection configuration using Ocp-Apim-Subscription-Key.

You can do this step in two ways. You can use any one of this.

  • Option 1 : Configure API Keys in ballerina file directly.

    Copy
    uggest:ApiKeysConfig apiKeyConfig = {
    cpApimSubscriptionKey:"<AZURE_API_KEY>"
    ubscriptionKey: "<Subscription Key>"
    
    
    uggest:Client myClient = check new Client(apiKeyConfig, serviceUrl);
  • Option 2 : Configure API Keys in Config.toml file and configure it in ballerina file, using configurables.

    1. Set up API Keys in Config.toml as shown below.
    [apiKeyConfig.apiKeys]
    ocpApimSubscriptionKey = "<AZURE_API_KEY>"
    subscriptionKey = "<Subscription Key>"
    
    1. Configure the client in ballerina file as shown below.
    Copy
    configurable ApiKeysConfig & readonly apiKeyConfig = ?;
    
    autosuggest:Client myClient = check new Client(apiKeyConfig, serviceUrl);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following operation provides suggestions for a given query or partial query.

    Copy
    public function main() returns error? {
        autosuggest:SentimentResponse res = check baseClient->sentiment(query);
    }
  2. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/bing.autosuggest;Copy

Metadata

Released date: 12 months ago

Version: 1.5.1

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes


Pull count

Total: 0

Current verison: 0


Weekly downloads


Source repository


Keywords

IT Operations/Cloud Services

Cost/Freemium

Vendor/Microsoft


Contributors

Other versions

See more...