Image search
With Yandex Search API, you can search for images through the Yandex Images
Searching by text description
To search by text description, provide your search parameters in the request body and get your search result in XML format.
Note
For parameters and examples of search queries via the Yandex Cloud ML SDK, see Searching by text description.
API request body format
The names of the request body fields are different in REST API and gRPC API: the former uses CamelCase
{
"query": {
"searchType": "<search_type>",
"queryText": "<search_query_text>",
"familyMode": "<result_filter_setting_value>",
"page": "<page_number>",
"fixTypoMode": "<typo_correction_mode_setting_value>"
},
"imageSpec": {
"format": "<image_format>",
"size": "<image_size>",
"orientation": "<image_orientation>",
"color": "<image_color>"
},
"site": "<website_domain_name>",
"docsOnPage": "<results_per_page>",
"folderId": "<folder_ID>",
"userAgent": "<User-Agent_header>"
}
Description of fields:
-
searchType: Search type. The possible values are:SEARCH_TYPE_RU: For theRussiansearch type.SEARCH_TYPE_TR: For theTurkishsearch type.SEARCH_TYPE_COM: For theInternationalsearch type.SEARCH_TYPE_KK: For theKazakhsearch type.SEARCH_TYPE_BE: For theBelarusiansearch type.SEARCH_TYPE_UZ: For theUzbeksearch type.
-
queryText: Search query text. The maximum length is 400 characters. -
familyMode: Results filtering. This is an optional parameter. The possible values are:FAMILY_MODE_MODERATE: Moderate filter (default). Adult category documents are excluded from search results unless the query explicitly targets resources of this category.FAMILY_MODE_NONE: Filtering is off. Search results include any documents regardless of their contents.FAMILY_MODE_STRICT: Family filter. Regardless of the search query, Adult category documents and documents containing profanity are excluded from search results.
-
page: Requested page number. This is an optional parameter. By default, the first page with search results is returned. Page numbering starts from zero (0stands for page one). -
fixTypoMode: Search query typo correction setting. This is an optional parameter. The possible values are:FIX_TYPO_MODE_ON: Typo correction enabled (default). Search query typos are corrected automatically.FIX_TYPO_MODE_OFF: Typo correction disabled. Search query typos are not corrected. The search is performed strictly as per the query.
-
format: Searching for images of specified format. This is an optional parameter. If not set, the search includes images of all formats. The possible values are: -
size: Searching for images of specified size. This is an optional parameter. If not set, the search includes images of all sizes. The possible values are:IMAGE_SIZE_ENORMOUS: Very large images (over1600 × 1200in pixels).IMAGE_SIZE_LARGE: Large images (from800 × 600to1600 × 1200in pixels).IMAGE_SIZE_MEDIUM: Medium images (from150 × 150to800 × 600in pixels).IMAGE_SIZE_SMALL: Small images (from32 × 32to150 × 150in pixels).IMAGE_SIZE_TINY: Icons (up to32 × 32in pixels).IMAGE_SIZE_WALLPAPER: Wallpaper images.
-
orientation: Searching for images of specified orientation. This is an optional parameter. If not set, the search includes images of any orientation. The possible values are:IMAGE_ORIENTATION_VERTICAL: Vertical images.IMAGE_ORIENTATION_HORIZONTAL: Horizontal images.IMAGE_ORIENTATION_SQUARE: Square aspect ratio images.
-
color: Searching for images with specified color parameters. This is an optional parameter. If not set, the search includes images with any color parameters. The possible values are:IMAGE_COLOR_COLOR: Colored images.IMAGE_COLOR_GRAYSCALE: Grayscale images.IMAGE_COLOR_RED: Images with red as the main color.IMAGE_COLOR_ORANGE: Images with orange as the main color.IMAGE_COLOR_YELLOW: Images with yellow as the main color.IMAGE_COLOR_GREEN: Images with green as the main color.IMAGE_COLOR_CYAN: Images with cyan as the main color.IMAGE_COLOR_BLUE: Images with blue as the main color.IMAGE_COLOR_VIOLET: Images with violet as the main color.IMAGE_COLOR_WHITE: Images with white as the main color.IMAGE_COLOR_BLACK: Images with black as the main color.
-
site: Searching for images only on specified website, e.g.,yandex.cloud. This is an optional parameter. If not set, the search includes all websites in the search base. -
docsOnPage: Number of result groups displayed per search result page. You can specify values between1and60. This is an optional parameter. The default value is20. -
folderId: Folder ID of the user or service account you will use for queries. -
userAgent: String containing the User-Agent header . Use this parameter to have your search results optimized for a specific device and browser, including mobile search results. This is an optional parameter. If not specified, you will get the default output.
{
"query": {
"search_type": "<search_type>",
"query_text": "<search_query_text>",
"family_mode": "<result_filter_setting_value>",
"page": "<page_number>",
"fix_typo_mode": "<typo_correction_mode_setting_value>"
},
"image_spec": {
"format": "<image_format>",
"size": "<image_size>",
"orientation": "<image_orientation>",
"color": "<image_color>"
},
"site": "<website_domain_name>",
"docs_on_page": "<results_per_page>",
"folder_id": "<folder_ID>",
"user_agent": "<User-Agent_header>"
}
Description of fields:
-
search_type: Search type. The possible values are:SEARCH_TYPE_RU: For theRussiansearch type.SEARCH_TYPE_TR: For theTurkishsearch type.SEARCH_TYPE_COM: For theInternationalsearch type.SEARCH_TYPE_KK: For theKazakhsearch type.SEARCH_TYPE_BE: For theBelarusiansearch type.SEARCH_TYPE_UZ: For theUzbeksearch type.
-
query_text: Search query text. The maximum length is 400 characters. -
family_mode: Results filtering. This is an optional parameter. The possible values are:FAMILY_MODE_MODERATE: Moderate filter (default). Adult category documents are excluded from search results unless the query explicitly targets resources of this category.FAMILY_MODE_NONE: Filtering is off. Search results include any documents regardless of their contents.FAMILY_MODE_STRICT: Family filter. Regardless of the search query, Adult category documents and documents containing profanity are excluded from search results.
-
page: Requested page number. This is an optional parameter. By default, the first page with search results is returned. Page numbering starts from zero (0stands for page one). -
fix_typo_mode: Search query typo correction setting. This is an optional parameter. The possible values are:FIX_TYPO_MODE_ON: Typo correction enabled (default). Search query typos are corrected automatically.FIX_TYPO_MODE_OFF: Typo correction disabled. Search query typos are not corrected. The search is performed strictly as per the query.
-
format: Searching for images of specified format. This is an optional parameter. If not set, the search includes images of all formats. The possible values are: -
size: Searching for images of specified size. This is an optional parameter. If not set, the search includes images of all sizes. The possible values are:IMAGE_SIZE_ENORMOUS: Very large images (over1600 × 1200in pixels).IMAGE_SIZE_LARGE: Large images (from800 × 600to1600 × 1200in pixels).IMAGE_SIZE_MEDIUM: Medium images (from150 × 150to800 × 600in pixels).IMAGE_SIZE_SMALL: Small images (from32 × 32to150 × 150in pixels).IMAGE_SIZE_TINY: Icons (up to32 × 32in pixels).IMAGE_SIZE_WALLPAPER: Wallpaper images.
-
orientation: Searching for images of specified orientation. This is an optional parameter. If not set, the search includes images of any orientation. The possible values are:IMAGE_ORIENTATION_VERTICAL: Vertical images.IMAGE_ORIENTATION_HORIZONTAL: Horizontal images.IMAGE_ORIENTATION_SQUARE: Square aspect ratio images.
-
color: Searching for images with specified color parameters. This is an optional parameter. If not set, the search includes images with any color parameters. The possible values are:IMAGE_COLOR_COLOR: Colored images.IMAGE_COLOR_GRAYSCALE: Grayscale images.IMAGE_COLOR_RED: Images with red as the main color.IMAGE_COLOR_ORANGE: Images with orange as the main color.IMAGE_COLOR_YELLOW: Images with yellow as the main color.IMAGE_COLOR_GREEN: Images with green as the main color.IMAGE_COLOR_CYAN: Images with cyan as the main color.IMAGE_COLOR_BLUE: Images with blue as the main color.IMAGE_COLOR_VIOLET: Images with violet as the main color.IMAGE_COLOR_WHITE: Images with white as the main color.IMAGE_COLOR_BLACK: Images with black as the main color.
-
site: Searching for images only on specified website, e.g.,yandex.cloud. This is an optional parameter. If not set, the search includes all websites in the search base. -
docs_on_page: Number of result groups displayed per search result page. You can specify values between1and60. This is an optional parameter. The default value is20. -
folder_id: Folder ID of the user or service account you will use for queries. -
user_agent: String containing the User-Agent header . Use this parameter to have your search results optimized for a specific device and browser, including mobile search results. This is an optional parameter. If not specified, you will get the default output.
XML response format
In response to a text search query, Yandex Search API returns a UTF-8
The XML file consists of request (with summarized information about the request parameters) and response (with search query processing results) grouping tags.
Note
The response contains no required fields. It may not return a field if there is no relevant data.
Response example
<?xml version="1.0" encoding="utf-8"?>
<yandexsearch version="1.0">
<request>
<query>kittens</query>
<page>0</page>
<sortby order="descending" priority="no">rlv</sortby>
<maxpassages>1</maxpassages>
<groupings>
<groupby attr="ii" mode="deep" groups-on-page="1" docs-in-group="1" curcateg="-1"/>
</groupings>
</request>
<response date="20250530T143927">
<reqid>1748615967169172-2797787793510975009-balancer-l7leveler-kubr-yp-vla-257-BAL</reqid>
<found priority="phrase">6558</found>
<found priority="strict">6558</found>
<found priority="all">6558</found>
<found-human>3 thsd. answers found</found-human>
<is-local>no</is-local>
<results>
<grouping attr="ii" mode="deep" groups-on-page="20" docs-in-group="1" curcateg="-1">
<page first="1" last="20">0</page>
<group>
<categ attr="ii" id="2606553042332394200"/>
<doccount>1</doccount>
<relevance priority="all"/>
<doc id="Z493B41CD68505D32">
<relevance priority="all"/>
<url>https://***.*****.**/wp-content/uploads/2015/08/three-kittens.jpg</url>
<domain>***.*****.**</domain>
<modtime>20191126T135649</modtime>
<size>0</size>
<charset>utf-8</charset>
<image-properties>
<id>082c71c2963a0b5859ac6de15743c7d661c76f4b-4665500-images-thumbs</id>
<shard>0</shard>
<thumbnail-link>http://avatars.mds.yandex.net/i?id=082c71c2963a0b5859ac6de15743c7d661c76f4b-4665500-images-thumbs</thumbnail-link>
<thumbnail-width>320</thumbnail-width>
<thumbnail-height>320</thumbnail-height>
<original-width>1374</original-width>
<original-height>1374</original-height>
<html-link>****************.com/category/enforcement/page/4/</html-link>
<image-link>****************.com/wp-content/uploads/2015/06/kittens1</image-link>
<file-size>130963</file-size>
<mime-type>jpg</mime-type>
</image-properties>
<mime-type>text/html</mime-type>
<properties/>
</doc>
</group>
<found priority="phrase">2348</found>
<found priority="strict">2348</found>
<found priority="all">2348</found>
<found-docs priority="phrase">2348</found-docs>
<found-docs priority="strict">2348</found-docs>
<found-docs priority="all">2348</found-docs>
<found-docs-human>found 1 thsd. answers</found-docs-human>
</grouping>
</results>
</response>
</yandexsearch>
request section
The request group provides aggregate information about request parameters. It may be missing if there are errors in the response.
|
Request group tags |
Description |
Attributes |
|
query |
Search query text |
None |
|
page |
Number of returned search results page. Page numbering starts from zero ( |
None |
|
sortby |
Result sorting parameters. Service tag, takes the |
|
|
maxpassages |
Maximum number of text snippets generated for each image. Service tag, takes the |
None |
|
groupings |
Grouping tag. It contains grouping parameters in the |
None |
|
groupby |
Parameters for grouping the search results. |
|
response section
Search query processing results. Contains the date attribute for query date and time (UTC<year><month><day>T<hour><minute><second> format.
Consists of the following sections:
General search results info
|
General search results info tags |
Description |
Attributes |
|
error |
Error description Used only if a search query is handled incorrectly (e.g., if the query is empty or parameters are incorrect). In some cases, it is mutually exclusive with other tags of the |
|
|
reqid |
Unique query ID |
None |
|
found |
Estimated number of images found based on the query. |
|
|
found-human |
A string in the language matching the selected search type. It shows the number of found images and related information. |
None |
results section
This is an optional section. It is present if results are found for the query.
|
results section tags |
Description |
Attributes |
|
results |
Grouping tag. Child tags contain information about search parameters and found images. |
None |
|
grouping |
Grouping tag. Child tags contain information about search parameters and found images. |
Attributes reflect the grouping rules for found images.
|
|
page |
Number of returned search results page. Page numbering starts from zero ( |
|
|
group |
Grouping tag. Each |
None |
|
categ |
Description of the found image. |
|
|
doccount |
Service tag. |
None |
|
relevance |
Service tag. |
|
|
doc |
Grouping tag. Each |
|
|
relevance |
Service tag. |
|
|
url |
Image address. |
None |
|
domain |
Domain hosting the document containing the image. |
None |
|
modtime |
Image modification date and time (UTC) in |
None |
|
size |
Image size in bytes. |
None |
|
charset |
Encoding of the document containing the image. |
None |
|
image-properties |
Grouping tag. Contains the image properties information to include in search results. |
None |
|
id |
Image thumbnail ID. |
None |
|
shard |
Number of the shard containing the image information. |
None |
|
thumbnail-link |
Image thumbnail address. |
None |
|
thumbnail-width |
Image thumbnail width in pixels. |
None |
|
thumbnail-height |
Image thumbnail height in pixels. |
None |
|
original-width |
Width of the source (original) image. |
None |
|
original-height |
Height of the source (original) image. |
None |
|
html-link |
Image page address. |
None |
|
image-link |
Image address. |
None |
|
file-size |
Image size in bytes. |
None |
|
mime-type |
Image format (JPG, GIF, or PNG). |
None |
|
mime-type |
Format of the document containing the image. |
None |
|
found |
Estimated number of generated groups. |
|
|
found-docs |
Estimated number of images found based on the query. It is a more accurate estimate compared to the value provided in the |
|
|
found-docs-human |
A string in the language matching the selected search type. It shows the number of found images and related information. The value being provided must be used when generating search results. |
None |
Searching by image
To search by image, provide the image and your search parameters in the request body and get your search result in JSON format.
Note
For parameters and examples of search queries via the Yandex Cloud ML SDK, see Searching for images by image.
API request body format
The names of the request body fields are different in REST API and gRPC API: the former uses CamelCase
{
"site": "<website_domain_name>",
"folderId": "<folder_ID>",
"url": "<source_image_URL>",
"data": "<image_data>",
"id": "<CBIR_ID>",
"page": "<page_number>"
}
Description of fields:
-
site: Searching for images only on specified website, e.g.,yandex.cloud. This is an optional setting. If not set, the search includes all websites in the search base. -
folderId: Folder ID of the user or service account you will use for queries. -
url: Source image URL. -
data: Source image data, Base64 -encoded. -
id: Source image CBIR ID. Specify the ID you got in the response to get the next search result page faster.Note
You can provide only one of these parameters in your query:
url,id, ordata. -
page: Requested page number. This is an optional setting. By default, the first page with search results is returned. Page numbering starts from zero (0stands for page one).
{
"site": "<website_domain_name>",
"folder_id": "<folder_ID>",
"url": "<source_image_URL>",
"data": "<image_data>",
"id": "<CBIR_ID>",
"page": "<page_number>"
}
Description of fields:
-
site: Searching for images only on specified website, e.g.,yandex.cloud. This is an optional setting. If not set, the search includes all websites in the search base. -
folder_id: Folder ID of the user or service account you will use for queries. -
url: Source image URL. -
data: Source image data, Base64 -encoded. -
id: Source image CBIR ID. Specify the ID you got in the response to get the next search result page faster.Note
You can provide only one of these parameters in your query:
url,id, ordata. -
page: Requested page number. This is an optional setting. By default, the first page with search results is returned. Page numbering starts from zero (0stands for page one).
JSON response format
In response to a query by image, Yandex Search API returns a UTF-8
Response example
{
"images": [
{
"url": "https://cs10.pikabu.ru/post_img/2019/10/29/8/og_og_1572352646221687176.jpg",
"format": "IMAGE_FORMAT_JPEG",
"width": "570",
"height": "960",
"passage": "This Pin was discovered by Some Dude.",
"host": "www.pinterest.com",
"pageTitle": "How to enrich your cute cats' life? Cute cats, Indoor cat, Cats",
"pageUrl": "https://www.pinterest.com/pin/how-to-enrich-your-cute-cats-life--703194929319013467/"
},
...
],
"page": "3",
"id": "1716254/_KnCt2T9gLh4z8SSv8nVqQ7277"
}
Description of fields:
-
images: Array of objects with information about found images:-
url: Image URL. -
format: Image format: -
width: Image width in pixels . -
height: Image height in pixels. -
passage: Text snippet describing the image. -
host: Domain hosting the document containing the image. -
pageTitle: Image page title. -
pageUrl: Image page URL.
-
-
page: Current search results page number. -
id: Source image CBIR ID.
{
"images": [
{
"url": "https://cs10.pikabu.ru/post_img/2019/10/29/8/og_og_1572352646221687176.jpg",
"format": "IMAGE_FORMAT_JPEG",
"width": "570",
"height": "960",
"passage": "This Pin was discovered by Some Dude.",
"host": "www.pinterest.com",
"page_title": "How to enrich your cute cats' life? Cute cats, Indoor cat, Cats",
"page_url": "https://www.pinterest.com/pin/how-to-enrich-your-cute-cats-life--703194929319013467/"
},
...
],
"page": "3",
"id": "1716254/_KnCt2T9gLh4z8SSv8nVqQ7277"
}
Description of fields:
-
images: Array of objects with information about found images:-
url: Image URL. -
format: Image format: -
width: Image width in pixels . -
height: Image height in pixels. -
passage: Text snippet describing the image. -
host: Domain hosting the document containing the image. -
page_title: Image page title. -
page_url: Image page URL.
-
-
page: Current search results page number. -
id: Source image CBIR ID.