General connection procedure
To submit queries to the Yandex search database using Yandex Search API via API v1, configure a service account.
Follow these steps to set up Yandex Search API to operate via API v1:
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.
-
In the list of services, select Identity and Access Management.
-
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 a role
Assign to the service account the search-api.executor
role it needs to query Yandex Search API via API v1.
- In the management console
, select the appropriate folder. - Go to the Access bindings tab.
- Click Configure access.
- In the window that opens, select Service accounts.
- Select a service account from the list or use the search.
- Click
Add role and select the role in the folder. - Click Save.
Create an API key
The service account will need a Yandex Search API API key for authentication in API v1. Create an API key for the service account:
- In the management console
, navigate to the folder the service account belongs to. - In the list of services, select Identity and Access Management.
- In the left-hand panel, select
Service accounts. - Select the service account to create an API key for. Create a new service account if you need to.
- 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.
- Optionally, select Scope. For more information about scopes, see API keys with scope and validity limits.
- Optionally, specify Expires at.
- Click Create.
- Save the ID and secret key.
Alert
After you close the dialog, the key value will become unavailable.
Registration
To use the API v1 interface, you must register in Yandex Search API:
-
In the management console
, select the folder you are going to use to work with Yandex Search API or create a new one. -
In the list of services, select Yandex Search API.
-
Fill in the form fields:
-
Select the Search type:
Russian
,Turkish
, orInternational
. -
Set at least one trusted IP address to send requests to the Yandex search database from.
You can send requests to Yandex Search API's API v1 only from one of the IP addresses added to the service settings during registration. Attempts to run a request from a non-registered IP address will be rejected.
-
-
Click Save.
After that, you will be able to change the search type and the trusted IP address list. In the management console
Create a test request
To interactively explore the principle of formation of Yandex Search API search queries via API v1, use the special query testing form:
-
In the management console
, select the folder you are going to use to work with Yandex Search API. -
In the list of services, select Yandex Search API.
-
In the left-hand panel, select
Test queries. -
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. Queries are submitted from a Yandex IP address on behalf of the service.
As the values in the form fields change, the search query URL for the specified values will be formed in the Search query field. If you select the
POST
method, a relevant query body will be formed in the Request body field. -
Click Run test. The query execution result will be displayed below.
-
If necessary, change the parameters to adjust the search results and resubmit your query.
Set up integration with Yandex Search API
- Learn about authentication in API v1 and configure querying.
- Configure response handling based on the response format in XML or HTML.
- If necessary, request information about hourly limits for the next 24 hours.