How to activate
To send requests to the Yandex search database using Yandex Search API, you need a service account.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Prepare a service account
Create a service account
-
Go to the management console
. -
On the left side of the screen, click the line with the name of the folder where you want to create a service account.
-
At the top of the screen, go to the Service accounts tab.
-
Click Create service account.
-
Enter a name for the service account.
The name format requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
Make sure the service account name is unique within your cloud.
-
Click Create.
Assign the required role
For your service account to send requests, it needs a role that allows using Search API. Assign the service account the search-api.executor
role:
- In the management console
, select the appropriate folder. - Go to the Access bindings tab.
- Click Assign bindings.
- In the window that opens, click
Select subject → Service accounts. - Select the required service account from the list or use the search.
- Click
Add role. - Select a role in the folder.
- Click Save.
Create an API key
For Search API authentication, the service account needs an API key. Create an API key for your service account:
- In the management console
, select the folder the service account belongs to. - At the top of the screen, go to the Service accounts tab.
- Choose a service account and click the row with its name. Create a new service account if needed.
- In the top panel, click
Create new key and select Create API key. - Enter a description of the key so that you can easily find it in the management console.
- Click Create.
- Save the ID and private key.
Alert
Once you close the dialog, the private key value will be unavailable.
To enable Search API and use it, follow these steps:
Registration
- In the management console
, select the folder to work with Search API in or create a new one. - Go to Search API.
- Fill in the form fields:
- Select the Search type:
Russian
,Turkish
, orInternational
. - Set at least one IP address to send requests to the Yandex search database from.
- Select the Search type:
- Click Save.
You can change the registration data later.
Create a test request
-
In the working folder, open Search API.
-
Go to the Test queries tab.
-
Select a Request method (GET and POST methods are supported) and fill in the form fields.
Note
You cannot edit the Search query text in a test query. Requests are sent from the Yandex IP address on behalf of the service.
-
Click Run test. Query execution results will be displayed below.
-
If necessary, change the parameters to adjust the search results and resend the request.
Set up integration with Search API
- Learn about the specifics of authentication in Yandex Cloud and set up request sending.
- Set up response handling depending on response format.
- If necessary, request information about hourly limits for the next day.