To perform a search on Google using the REST APIs, we need to create a Custom Search Engine (referred from now on as CSE). We also need to enable Custom Search API for the account using which we are going to create CSE.
Google Search Service on Intelligence Platform needs 2 IDs to execute the search operation, CSE ID and Custom Search API Key. The free version of CSE only allows upto 100 searches/day using a single ID/Key pair. After that, the ID/Key Pair expires and is reset the next day.
IMPORTANT: Please make sure your Google Search instance must be accessible from the Klera Machine.
API Rate Limit: 10000 requests per day
Steps to create Credentials
Following are the steps to create CSE ID and API Key for your account –
Steps to create CSE ID
- Open https://cse.google.com/ and login using your personal account.
- Click “New Search Engine”.
- In “Site to Search” enter www.example.com.
- Select language as English.
- Provide a name to the search engine and click “Create”.
- Click on “Edit Search Engine” and select the search engine created in steps above.
- Click on “Setup”.
- Click “Search Engine ID” button and save the ID (say 'cx'). This will be required in later part of the document.
- Turn on “Search the entire web” down to "Site to Search".
- Select www.example.com and click delete.
- Click Update.
Steps to Enable Custom Search API
- Open https://console.developers.google.com and login using your personal account.
- In the Top Left section, click the drop-down “Select a Project” and click “Create a Project”.
- Fill the Project name, click no for “email updates” and “yes” to “agree terms and conditions” and click “Create” button.
- Click on “Enable APIs and Services” and search for “Custom Search API” in “Google APIs” tab.
- Click on “Custom Search API” in search results and click “Enable” on the following page.
Steps to Create API Key
- After “Enabling”, click on “Go to Credentials”.
- Click on "CREATE CREDENTIALS" and it will give you an API Key.
- Save the key(say 'key') as it will be required in later part of the document.
Configuration on Klera
To configure Google Search using Token based authentication, follow the steps below:-
- Right click on the floor, go to Connectors→ Import.
- Import the Google Search Connector.zip file.
- Right click on the floor, go to Connectors→ Show.
- Right click on the entity of column “Google Search Connector” and go to Connectors → Connections → Configure.
- Enter Google Search URL i.e. https://www.googleapis.com
- Select “Create New Account” and add user friendly name for account “Google Search Account”
- Select Authentication Type as "Token" and enter the details for the below Token Parameters:
- Token Parameter key : "cx"
value : <Your Search Engine Id>
Click the plus icon ('+') present at the end of this row to add a new token parameter and add
- Token Parameter key : "key"
value : <Your API Key>
Please refer the below image to get more clarity.
- Token Parameter key : "cx"
- Click on “Save”.