View as PDF - Yandex API
View as PDF - Yandex API
View as PDF - Yandex API
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Yandex</strong>.XML<br />
Developer's guide<br />
16.10.2014
<strong>Yandex</strong>.XML. Developer's guide. Version 1.2<br />
Document build date: 16.10.2014.<br />
This volume is a part of <strong>Yandex</strong> technical documentation.<br />
<strong>Yandex</strong> helpdesk site: http://help.yandex.ru<br />
© 2008—2014 <strong>Yandex</strong> LLC. All rights reserved.<br />
Copyright Disclaimer<br />
<strong>Yandex</strong> (and its applicable licensor) h<strong>as</strong> exclusive rights for all results of intellectual activity and equated to them means of individualization, used for development, support,<br />
and usage of the service <strong>Yandex</strong>.XML. It may include, but not limited to, computer programs (software), datab<strong>as</strong>es, images, texts, other works and inventions, utility models,<br />
trademarks, service marks, and commercial denominations. The copyright is protected under provision of Part 4 of the Russian Civil Code and international laws.<br />
You may use <strong>Yandex</strong>.XML or its components only within credentials granted by the Terms of Use of <strong>Yandex</strong>.XML or within an appropriate Agreement.<br />
Any infringements of exclusive rights of the copyright owner are punishable under civil, administrative or criminal Russian laws.<br />
Contact information<br />
<strong>Yandex</strong> LLC<br />
http://www.yandex.com<br />
Phone: +7 495 739 7000<br />
Email: pr@yandex-team.ru<br />
Headquarters: 16 L'va Tolstogo St., Moscow, Russia 119021
Contents<br />
Overview .............................................................................................................................................................................................. 4<br />
Restrictions and requirements .............................................................................................................................................................. 4<br />
Getting started ...................................................................................................................................................................................... 5<br />
Registration .......................................................................................................................................................................................... 6<br />
Request for search results ................................................................................................................................................................. 7<br />
GET requests ................................................................................................................................................................................ 7<br />
POST requests .............................................................................................................................................................................. 9<br />
Response format ....................................................................................................................................................................... 11<br />
request ................................................................................................................................................................................ 13<br />
response .............................................................................................................................................................................. 14<br />
Request for limits for the next day ................................................................................................................................................. 19<br />
Response format ......................................................................................................................................................................... 19<br />
Formatting results .............................................................................................................................................................................. 21<br />
Protection from robots ....................................................................................................................................................................... 21<br />
Questions and answers .................................................................................................................................................................... 24<br />
What is XSLT .......................................................................................................................................................................... 24<br />
Notifications ............................................................................................................................................................................... 24<br />
IP address ................................................................................................................................................................................... 25<br />
Additional search features .......................................................................................................................................................... 26<br />
Encoding .................................................................................................................................................................................... 27<br />
Appendices ........................................................................................................................................................................................ 28<br />
Validating XML files ................................................................................................................................................................. 28<br />
Error codes ................................................................................................................................................................................. 28<br />
Search regions ............................................................................................................................................................................ 29<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
4<br />
Overview<br />
<strong>Yandex</strong>.XML is a service that lets you send queries to the <strong>Yandex</strong> search engine and get responses in XML<br />
format.<br />
This document covers restrictions and requirements for using the service, b<strong>as</strong>ic steps for getting started<br />
and registering, formats of search queries and responses, and answers to common questions.<br />
The document is intended for developers who need to set up a search across a web site, group of sites, or the<br />
Internet.<br />
Restrictions and requirements<br />
<strong>Yandex</strong>.XML provides access to Russian, Turkish, and Worldwide types of search. The desired search type<br />
is selected during registration.<br />
The search type determines the ranking formula, the set of documents that are searched (the search b<strong>as</strong>e), and the<br />
restrictions that are applied to usage of <strong>Yandex</strong>.XML.<br />
The following types of restrictions are applied:<br />
• Limit to the number of IP addresses that are <strong>as</strong>sociated with the account (by default, one).<br />
• Daily limits on the number of search queries sent. If the IP address changes, the limit applies to the total<br />
number of queries sent from all network addresses.<br />
The following table provides information about how restrictions depend on the search type and other conditions.<br />
Condition “Russian” search type “Turkish” search type “Worldwide” search<br />
type<br />
Telephone number is not<br />
confirmed.<br />
Restrictions<br />
be changed.<br />
cannot<br />
10 search queries per day. 10 search queries per day.<br />
Telephone number<br />
confirmed.<br />
Restriction:<br />
One telephone number<br />
may be confirmed no more<br />
than once, and only for a<br />
single account.<br />
Restrictions<br />
be changed.<br />
cannot<br />
10,000 search queries<br />
per day.<br />
10,000 search queries<br />
per day.<br />
The web site is registered<br />
in <strong>Yandex</strong>.Webm<strong>as</strong>ter<br />
The number of search queries<br />
allowed is determined<br />
individually for each user.<br />
Restrictions depend on the<br />
sites<br />
registered<br />
in <strong>Yandex</strong>.Webm<strong>as</strong>ter.<br />
Restrictions<br />
be changed.<br />
cannot<br />
Restrictions<br />
be changed.<br />
cannot<br />
Hourly restrictions are also<br />
applied.<br />
License agreement<br />
http://legal.yandex.ru/xml<br />
http://legal.yandex.com.tr/<br />
xml<br />
http://legal.yandex.com/xml<br />
Changing restrictions (incre<strong>as</strong>ing the maximum number of queries per day and IP addresses allowed)<br />
Become a partner of the<br />
<strong>Yandex</strong> Advertising<br />
Network.<br />
Contact a <strong>Yandex</strong><br />
representative and discuss<br />
how to expand your use of<br />
<strong>Yandex</strong>.XML features.<br />
Contact a <strong>Yandex</strong><br />
representative and discuss<br />
how to expand your use of<br />
<strong>Yandex</strong>.XML features.<br />
To get information about additional features of <strong>Yandex</strong>.XML and how to get access to them, contact a <strong>Yandex</strong><br />
representative.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
5<br />
For each search query, no more than 1000 results are returned.<br />
When using the service, follow the requirements for formatting results and the recommendations for protection<br />
from robots.<br />
Hourly limits for the “Russian” search type<br />
For the “Russian” search type, additional hourly limits may be imposed that are calculated <strong>as</strong> percentages of the<br />
daily query limit.<br />
Information about hourly limits is available on the page Information on restrictions after registration.<br />
The daily limit on the number of queries for a site is 1000. During each hour in the period from 7:00 to 19:00, no more<br />
than 5% of the queries for this limit can be sent (50 queries).<br />
Even if there were no search queries sent from the account in the period from 0:00 to 7:00, no more than 50 queries can be<br />
sent during each hour from 7:00 to 19:00. In total, no more than 600 queries can be sent over this period.<br />
Getting started<br />
To set up and start using <strong>Yandex</strong>.XML, follow these steps:<br />
1. Register the IP address that you plan to send search requests from.<br />
2. Send a test request.<br />
Make sure that requests are sent successfully from the specified IP address:<br />
• Send a request from the service's interface. The interface should be accessed from the computer that<br />
is <strong>as</strong>signed the IP address specified during registration.<br />
• Form a GET request and send it from the computer that is <strong>as</strong>signed the IP address that w<strong>as</strong> specified<br />
during registration. For example, if during registration the field URL for queries displayed the string<br />
“http://xmlsearch.yandex.ru/xmlsearchuser=test-yandex&key=09.31114:e650g7j”, you would use the<br />
following GET request:<br />
http://xmlsearch.yandex.ru/xmlsearchuser=testyandex&key=09.31114:e650g7j&query=yandex<br />
3. Check the received XML document.<br />
The response should correspond to the specified format and should not contain errors.<br />
Note:<br />
If there are no results for the search string, an error with the code “15” is acceptable.<br />
4. Only for the “Russian” search type. Register your web sites in the <strong>Yandex</strong>.Webm<strong>as</strong>ter service. After<br />
registration, individual restrictions are determined for the current user.<br />
5. Only for the “Russian” search type. Review the daily and hourly restrictions on the Information about<br />
restrictions page.<br />
<strong>Yandex</strong>.XML can only be used on sites for which the current user is the main owner in the<br />
<strong>Yandex</strong>.Webm<strong>as</strong>ter service. If necessary, <strong>as</strong>k the site owner to <strong>as</strong>sign you the appropriate role.<br />
6. Configure request parameters.<br />
The GET and POST methods are supported.<br />
7. Review the response format.<br />
8. Set up response handling.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
6<br />
For formatting search results, you must comply with the design requirements.<br />
9. If necessary. Request information about hourly restrictions for the next 24 hours.<br />
10. Optional. Set up protection from robots.<br />
Registration<br />
To register on the <strong>Yandex</strong>.XML service, follow these steps:<br />
1. Open the registration page (http://xml.yandex.com.tr/settings.xml).<br />
This requires authentication in <strong>Yandex</strong>.P<strong>as</strong>sport. If necessary, first register.<br />
2. Look at the value of the URL for queries field:<br />
• For GET requests, this is the b<strong>as</strong>e part of the address that request parameters are appended to.<br />
• For POST requests, this is the URL to send the request body to.<br />
3. Fill in the fields on the form:<br />
Field<br />
Main IP-address<br />
Search type<br />
Email notifications<br />
List of events<br />
Notification<br />
language<br />
Description<br />
The unique network address of the computer that will be sending search queries.<br />
To set the IP address of the computer you are using to register, use the value of the Your<br />
current IP-address is field.<br />
The selected value determines the set of documents that are searched (the search b<strong>as</strong>e),<br />
the ranking formula, and usage restrictions.<br />
The email address to send notifications to.<br />
Choose events that notifications should be sent for.<br />
The language to use for delivering messages about selected events.<br />
4. Review the terms of the license agreement. The terms depend on the search type you selected.<br />
5. Confirm your agreement (select the box I accept the terms of License Agreement).<br />
6. Save the information you have entered (the Save button is enabled when the Email notifications and I<br />
accept the terms of License Agreement boxes have been filled in).<br />
If necessary, registration data can be edited on the Settings page.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
7<br />
Request for search results<br />
<strong>Yandex</strong>.XML supports two ways of sending a search request: GET and POST.<br />
The response format is the same for both supported methods.<br />
Attention!<br />
To use algorithms for protection from robots, the request must p<strong>as</strong>s information about the IP address and the<br />
"spravka" cookie for the query author.<br />
GET requests<br />
Attention!<br />
Special characters that are p<strong>as</strong>sed <strong>as</strong> parameter values must be replaced with the appropriate escape sequences<br />
for percent-encoding. For example, instead of the equal sign (“=”), the escape sequence “%3D” must be used.<br />
Request format<br />
http://xmlsearch.yandex./xmlsearch <br />
user=<br />
& key=<br />
& query=<br />
& [lr=]<br />
& [l10n=]<br />
& [sortby=]<br />
& [filter=]<br />
& [maxp<strong>as</strong>sages=]<br />
& [groupby=]<br />
& [page=]<br />
& [showmecaptcha=]<br />
user<br />
key<br />
query<br />
lr<br />
l10n<br />
User name. Must match the login for <strong>Yandex</strong>.P<strong>as</strong>sport that w<strong>as</strong> set during registration.<br />
Value of the <strong>API</strong> key that w<strong>as</strong> issued during registration.<br />
Text of the search query. Instead of special symbols, the corresponding escape sequences must be used.<br />
The query h<strong>as</strong> the following restrictions: maximum query length — 400 characters; maximum number<br />
of words — 40.<br />
Supported only for “Russian” and “Turkish” search types.<br />
ID of the country or region to search. Determines the rules for ranking documents. For example, if we<br />
p<strong>as</strong>s the value “11316” in this parameter (Novosibirsk region), when generating search results, a formula<br />
is used that is defined for the Novosibirsk region.<br />
A list of IDs of common countries and regions is provided in the appendix.<br />
The notification language for the search response. It affects the text that is p<strong>as</strong>sed in the found-docshuman<br />
tag, <strong>as</strong> well <strong>as</strong> in error messages.<br />
Acceptable values depend on the type of search used:<br />
• “Russian (yandex.ru)” — “ru” (Russian), “uk” (Ukrainian), “be” (Belarusian), “kk” (Kazakh).<br />
If omitted, notifications are sent in Russian.<br />
• “Turkish (yandex.com.tr)” — Supports only the value “tr” (Turkish).<br />
• “Worldwide (yandex.com)” — Supports only the value “en” (English).<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
8<br />
sortby<br />
Rules for sorting search results. Possible values:<br />
• “rlv” — By relevancy.<br />
• “tm” — By time when the document w<strong>as</strong> changed.<br />
If omitted, results are sorted by relevancy.<br />
When sorting by change time, the parameter may contain the order attribute, which is the order<br />
for sorting documents. Possible values:<br />
• “descending” — Forward (from most recent to oldest). Used by default.<br />
• “<strong>as</strong>cending” — Reverse (from oldest to most recent).<br />
Format: sortby=.order%3D. For example, for reverse<br />
sorting by date, you must use the following construction: sortby=tm.order%3Descending.<br />
filter<br />
Rules for filtering search results (excluding documents from search results b<strong>as</strong>ed on one of the rules).<br />
Possible values:<br />
• “none” — Filtering is disabled. The output includes any documents, regardless of their content.<br />
• “moderate” — Moderate filtering. The output excludes documents that fall into the “adults only”<br />
category, if the search is not explicitly directed at finding these types of resources.<br />
• “strict” — Family filter. Regardless of the search query, the output excludes documents that fall<br />
into the “adults only” category, <strong>as</strong> well <strong>as</strong> those that contain foul language.<br />
If the parameter is omitted, moderate filtering is used.<br />
maxp<strong>as</strong>sages<br />
groupby<br />
page<br />
The maximum number of p<strong>as</strong>sages that can be used when creating a snippet for the document. A p<strong>as</strong>sage<br />
is an excerpt from a found document that contains the query words. P<strong>as</strong>sages are used for creating<br />
snippets, which are textual annotations to found documents.<br />
Acceptable values — from 1 to 5. The search result may contain fewer p<strong>as</strong>sages than the value set for<br />
this parameter.<br />
If the parameter is omitted, no more than four p<strong>as</strong>sages with the query text are returned for each<br />
document.<br />
Set of parameters that define the rules for grouping results. Grouping is used to put documents from<br />
the same domain in a container. Within the container, documents are ranked using the sorting rules<br />
defined in the sortby parameter. Results p<strong>as</strong>sed to the container can be used for including several<br />
documents from the same domain in search output.<br />
Parameters are comma-separated and set in the format:<br />
attr%3D.mode%3D.groups-on-page<br />
%3D.docs-in-group%3D<br />
You can find a description of the parameters mode, attr, groups-on-page and docs-in-group in the section<br />
POST requests.<br />
Number of the requested page in the search output. This determines the range of document positions<br />
returned for the request. Numbering starts from zero (the first page corresponds to the value “0”).<br />
For example, if the number of documents returned on a page is equal to “n”, and the value “p” is p<strong>as</strong>sed<br />
in the parameter, the search results will include documents that fall within the range of output positions<br />
from (p+1)*n+1 to (p+1)*n+n inclusively.<br />
If the parameter is omitted, the first page of search output is returned.<br />
showmecaptcha<br />
Initiates user verification for possible protection from robots.<br />
The only value used is “yes”.<br />
Sample GET request<br />
The following request returns the second page of search results for the query “” for the user “xml-search-user”.<br />
Search type: Russian (yandex.ru). Results are grouped by domain. Each group contains three documents, and five groups<br />
can be returned per page.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
9<br />
http://xmlsearch.yandex.ru/xmlsearchuser=xml-searchuser&key=03.44583456:c876e1b098gh65khg834ggg1jk4ll9j8&query=%3Ctable%3E&groupby=attr<br />
%3Dd.mode%3Ddeep.groups-on-page%3D5.docs-in-group%3D3&maxp<strong>as</strong>sages=3&page=1<br />
POST requests<br />
Attention!<br />
Special characters that are p<strong>as</strong>sed <strong>as</strong> parameter values in the request body must be replaced with the appropriate<br />
escape sequences for XML-encoding. For example, instead of the ampersand sign (“&”), the escape sequence<br />
“&” must be used.<br />
Request URL<br />
http://xmlsearch.yandex./xmlsearch <br />
user=<br />
& key=<br />
& filter=<br />
& [lr=]<br />
& [l10n=]<br />
& [showmecaptcha=]<br />
user<br />
key<br />
filter<br />
User name. Must match the login for <strong>Yandex</strong>.P<strong>as</strong>sport that w<strong>as</strong> set during registration.<br />
Value of the <strong>API</strong> key that w<strong>as</strong> issued during registration.<br />
Rules for filtering search results (excluding documents from search results b<strong>as</strong>ed on one of the rules).<br />
Possible values:<br />
• “none” — Filtering is disabled. The output includes any documents, regardless of their content.<br />
• “moderate” — Moderate filtering. The output excludes documents that fall into the “adults only”<br />
category, if the search is not explicitly directed at finding these types of resources.<br />
• “strict” — Family filter. Regardless of the search query, the output excludes documents that fall<br />
into the “adults only” category, <strong>as</strong> well <strong>as</strong> those that contain foul language.<br />
If the parameter is omitted, moderate filtering is used.<br />
lr<br />
l10n<br />
Supported only for “Russian” and “Turkish” search types.<br />
ID of the country or region to search. Determines the rules for ranking documents. For example, if we<br />
p<strong>as</strong>s the value “11316” in this parameter (Novosibirsk region), when generating search results, a formula<br />
is used that is defined for the Novosibirsk region.<br />
A list of IDs of common countries and regions is provided in the appendix.<br />
The notification language for the search response. It affects the text that is p<strong>as</strong>sed in the found-docshuman<br />
tag, <strong>as</strong> well <strong>as</strong> in error messages.<br />
showmecaptcha<br />
Acceptable values depend on the type of search used:<br />
• “Russian (yandex.ru)” — “ru” (Russian), “uk” (Ukrainian), “be” (Belarusian), “kk” (Kazakh).<br />
If omitted, notifications are sent in Russian.<br />
• “Turkish (yandex.com.tr)” — Supports only the value “tr” (Turkish).<br />
• “Worldwide (yandex.com)” — Supports only the value “en” (English).<br />
Initiates user verification for possible protection from robots.<br />
The only value used is “yes”.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
10<br />
Request body format<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Parameter<br />
request<br />
query<br />
sortby<br />
Description<br />
Grouping tag. Child tags contain parameters of the search query.<br />
Text of the search query. Instead of special symbols, the corresponding escape sequences<br />
must be used.<br />
The query h<strong>as</strong> the following restrictions: maximum query length — 400 characters;<br />
maximum number of words — 40.<br />
Rules for sorting search results. Possible values:<br />
• “rlv” — By relevancy.<br />
• “tm” — By time when the document w<strong>as</strong> changed.<br />
If omitted, results are sorted by relevancy.<br />
When sorting by change time, the parameter may contain the order attribute, which is the<br />
order for sorting documents. Possible values:<br />
• “descending” — Forward (from most recent to oldest). Used by default.<br />
• “<strong>as</strong>cending” — Reverse (from oldest to most recent).<br />
maxp<strong>as</strong>sages<br />
page<br />
The maximum number of p<strong>as</strong>sages that can be used when creating a snippet for the<br />
document. A p<strong>as</strong>sage is an excerpt from a found document that contains the query words.<br />
P<strong>as</strong>sages are used for creating snippets, which are textual annotations to found documents.<br />
Acceptable values — from 1 to 5. The search result may contain fewer p<strong>as</strong>sages than<br />
the value set for this parameter.<br />
If the parameter is omitted, no more than four p<strong>as</strong>sages with the query text are returned<br />
for each document.<br />
Number of the requested page in the search output. This determines the range of document<br />
positions returned for the request. Numbering starts from zero (the first page corresponds<br />
to the value “0”).<br />
For example, if the number of documents returned on a page is equal to “n”, and the value<br />
“p” is p<strong>as</strong>sed in the parameter, the search results will include documents that fall within<br />
the range of output positions from (p+1)*n+1 to (p+1)*n+n inclusively.<br />
If the parameter is omitted, the first page of search output is returned.<br />
Group tag groupings. The child tag contains parameters for grouping results.<br />
groupby<br />
Set of parameters that define the rules for grouping results. Grouping is used to put<br />
documents from the same domain in a container. Within the container, documents are ranked<br />
using the sorting rules defined in the sortby parameter. Results p<strong>as</strong>sed to the container<br />
can be used for including several documents from the same domain in search output.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
11<br />
Parameter<br />
Description<br />
Contains the following attributes:<br />
• mode — Grouping method. Possible values:<br />
• “flat” — Flat grouping. Each group contains a single document. P<strong>as</strong>sed with<br />
an empty value for the attr parameter (“" "”).<br />
• “deep” — Grouping by domain. Each group contains documents from a single<br />
domain. P<strong>as</strong>sed with the value “d” for the attr parameter.<br />
If the parameter is not defined, flat grouping is used.<br />
• attr — Utility attribute. Depends on the value of the mode attribute.<br />
• groups-on-page — Maximum number of groups that can be returned per page<br />
of search results. Acceptable values — from 1 to 100.<br />
• docs-in-group — Maximum number of documents that can be returned per group.<br />
Acceptable values — from 1 to 3.<br />
Tip:<br />
If necessary, use the XML feed validator in the <strong>Yandex</strong>.Webm<strong>as</strong>ter service. Detailed information about<br />
validation is provided in the appendix.<br />
Sample POST request<br />
The request and request URL shown below return the third page of search results for the query “” for the user “xmlsearch-user”.<br />
Results are sorted by time when the document w<strong>as</strong> changed. Search type: Russian (yandex.ru). Results<br />
are grouped by domain. Each group contains three documents, and ten groups can be returned per page. The maximum<br />
number of p<strong>as</strong>sages per document is two. The service returns an XML file in UTF-8 encoding.<br />
Request URL:<br />
http://xmlsearch.yandex.ru/xmlsearchuser=xml-searchuser&key=03.44583456:c876e1b098gh65khg834ggg1jk4ll9j8<br />
Request body:<br />
<br />
<br />
%3Ctable%3E<br />
tm<br />
2<br />
2<br />
<br />
<br />
<br />
<br />
Response format<br />
In response to the search request, <strong>Yandex</strong>.XML returns an XML file in UTF-8 encoding that contains the search<br />
results.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
12<br />
Restriction:<br />
No more than 1000 results are returned for each search query. Depending on the value of the docs-in-group<br />
attribute, each result may contain from one to three documents. The maximum number of pages with search<br />
results is determined by the number of document groups returned on each page (the value of the groups-onpage<br />
attribute). For example, if the groups-on-page attribute is p<strong>as</strong>sed with the value “10”, no more than<br />
100 pages containing search results can be made.<br />
Files consist of the grouping tags request (general information about query parameters) and response (results<br />
of processing the search query).<br />
Below you will find the general structure of a resulting XML document with sample values.<br />
Attention!<br />
This structure is for illustrative purposes. It contains mutually exclusive elements.<br />
<br />
<br />
<br />
yandex<br />
0<br />
rlv<br />
2<br />
<br />
<br />
<br />
<br />
<br />
Sorry, there are no results for this search<br />
1348828873568466-1289158387737177180255457-3-011-XML<br />
206775197<br />
206775197<br />
206775197<br />
207 million pages found<br />
<br />
Misspell<br />
yandexx<br />
yandex<br />
<br />
<br />
Misspell<br />
yndex<br />
yandex<br />
yandex<br />
<br />
<br />
<br />
45094<br />
45094<br />
45094<br />
192685602<br />
192685602<br />
192685602<br />
193 million pages found<br />
0<br />
<br />
<br />
34<br />
<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
13<br />
<br />
<br />
http://www.yandex.ru/<br />
www.yandex.ru<br />
"<strong>Yandex</strong>" is a global search engine<br />
and internet portal<br />
Search the entire internet b<strong>as</strong>ed on the user's region.<br />
20060814T040000<br />
26938<br />
utf-8<br />
<br />
<strong>Yandex</strong> — a search engine...<br />
<br />
<br />
0<br />
ru<br />
<br />
text/html<br />
http://hghltd.yandex.net/yandbtm<br />
text=yandex&url=http%3A%2F%2Fwww.yandex.ru<br />
%2F&fmode=inject&mime=html&l10n=ru&sign=e3737561fc3d1105967d1ce6<br />
19dbd3c7&keyno=0<br />
<br />
<br />
<br />
<br />
<br />
<br />
request<br />
Generalized information about request parameters. May be omitted if the response contains errors.<br />
The request tags are described in the table below.<br />
The "request"<br />
group tags<br />
Description<br />
query Text of the search query that w<strong>as</strong> p<strong>as</strong>sed. None.<br />
Attributes<br />
page<br />
sortby<br />
maxp<strong>as</strong>sages<br />
groupings<br />
Number of the search results page returned. Numbering starts<br />
from zero (the first page corresponds to the value “0”).<br />
Parameters for sorting results Possible values:<br />
• “rlv” — By relevancy.<br />
• “tm” — By time when the document w<strong>as</strong> changed.<br />
Maximum number of p<strong>as</strong>sages that can be p<strong>as</strong>sed in a single<br />
search result.<br />
Grouping.<br />
Contains grouping parameters in the groupby tag.<br />
No attributes<br />
None.<br />
• order — Sorting order.<br />
The “descending” value<br />
(forward) is used by default.<br />
When sorting by change time,<br />
it can take the value<br />
“<strong>as</strong>cending” (reverse).<br />
• priority — For service use.<br />
Takes the value "no".<br />
None.<br />
None.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
14<br />
The "request"<br />
group tags<br />
groupby<br />
Description<br />
Grouping parameters for found search results.<br />
Attributes<br />
• mode — Grouping method.<br />
• attr — For service use.<br />
• groups-on-page —<br />
Maximum number of groups<br />
that can be returned per page<br />
of search results.<br />
• docs-in-group —<br />
Maximum number<br />
of documents that can be<br />
returned per group. Any group<br />
may contain fewer documents<br />
than the value set in this<br />
parameter.<br />
• curcateg — For service use.<br />
Takes the value “-1”.<br />
The following example shows the contents of the request grouping tag that are returned for the request http://<br />
xmlsearch.yandex.com.tr/xmlsearchlr=983&l10n=tr&user=xml-searchuser&key=03.79031114:b631r9j587dkl4jko987hgg7bn2kl8a2&query=%22h<strong>as</strong><br />
sample<br />
applications for the most popular programming<br />
%22&sortby=tm&maxp<strong>as</strong>sages=2&groupby=attr%3Dd.mode%3Ddeep.groups-on-page<br />
%3D5.docs-in-group%3D3&maxp<strong>as</strong>sages=3&page=1<br />
<br />
"h<strong>as</strong> sample applications for the most popular programming"<br />
1<br />
tm<br />
2<br />
<br />
<br />
<br />
<br />
response<br />
Results of processing the search query for which information is provided in the request child tags.<br />
Contains the date attribute — the request date and time, in the format<br />
Т for UTC.<br />
Consists of the following sections:<br />
• General information about search results.<br />
• The misspell / re<strong>as</strong>k block.<br />
• The results block.<br />
General information about search results<br />
The tags for the block with general information about search results are shown in the table below.<br />
Tags with general<br />
information about<br />
search results<br />
error<br />
Description<br />
Error description.<br />
Present only when the search request is processed incorrectly<br />
(for example, for an empty request, incorrect parameters,<br />
etc.).<br />
Attributes<br />
code — Error code.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
15<br />
Tags with general<br />
information about<br />
search results<br />
Description<br />
In certain c<strong>as</strong>es, it is mutually exclusive of other tags in the<br />
response grouping tag.<br />
Attributes<br />
reqid Unique request ID. None.<br />
found<br />
Approximation of the number of documents found for the<br />
query.<br />
priority — For service use.<br />
Possible values:<br />
• “phr<strong>as</strong>e”<br />
• “strict”<br />
• “all”<br />
found-human<br />
A string in the language corresponding to the search type<br />
selected. Contains information about the number<br />
of documents found and accompanying information.<br />
None.<br />
The misspell / re<strong>as</strong>k block<br />
Optional. Present if a typo w<strong>as</strong> found (misspell) or corrected (re<strong>as</strong>k) in the query.<br />
The block tags are presented in the table below.<br />
Tags for the<br />
misspell / re<strong>as</strong>k<br />
blocks<br />
misspell<br />
Description<br />
Grouping.<br />
Contains information about a possible typo in the search<br />
query.<br />
Attributes<br />
None.<br />
re<strong>as</strong>k<br />
rule<br />
source-text<br />
text-to-show<br />
Grouping.<br />
Contains information about corrections made to the source<br />
query before searching for documents.<br />
The type of error found in the query.<br />
Possible values:<br />
• “Misspell” — Typo.<br />
• “KeyboardLayout” — Wrong keyboard layout.<br />
• “Volapyuk” — Query made in Russian using English<br />
transliteration. Used if the search type is set to “Russian<br />
(yandex.ru)”.<br />
Source text of the query.<br />
The fragment of the search query that presumably contains<br />
an error is highlighted by the hlword tag.<br />
Optional (only for the re<strong>as</strong>k grouping tag).<br />
Contains the corrected text of the search query. In most c<strong>as</strong>es<br />
it matches the value p<strong>as</strong>sed in the text tag.<br />
None.<br />
None.<br />
None.<br />
None.<br />
text Corrected text of the search query. None.<br />
The results block<br />
Optional. Present if results were found for the query.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
16<br />
The block tags are presented in the table below.<br />
Tags for the results<br />
block<br />
results<br />
Description<br />
Grouping. Child tags contain information about search<br />
parameters and found documents.<br />
Attributes<br />
None.<br />
grouping<br />
Grouping. Child tags contain information about search<br />
parameters and found documents.<br />
Attributes reflect the grouping rules<br />
for found documents.<br />
• mode — Grouping method.<br />
• attr — For service use.<br />
Depends on the value of the<br />
mode attribute.<br />
• groups-on-page —<br />
Number of groups that can be<br />
returned per page of search<br />
results.<br />
• docs-in-group —<br />
Number of documents that<br />
can be returned per group.<br />
• curcateg — For service use.<br />
Takes the value “-1”.<br />
found Estimated number of groups formed. priority — For service use.<br />
Possible values:<br />
• “phr<strong>as</strong>e”<br />
• “strict”<br />
• “all”<br />
found-docs<br />
Approximation of the number of documents found for the<br />
query.<br />
A more precise estimate compared to the value p<strong>as</strong>sed in the<br />
found tag for the block with general information about search<br />
results.<br />
priority — For service use.<br />
Possible values:<br />
• “phr<strong>as</strong>e”<br />
• “strict”<br />
• “all”<br />
found-docshuman<br />
A string in the language corresponding to the search type<br />
selected. Contains information about the number<br />
of documents found and accompanying information.<br />
The value that is p<strong>as</strong>sed should be used when formatting<br />
search results.<br />
None.<br />
page<br />
group<br />
Number of the search results page returned. Numbering starts<br />
from zero (the first page corresponds to the value “0”).<br />
Grouping.<br />
Each group tag contains information about a found group<br />
of documents.<br />
• first — Ordinal number<br />
of the first group with search<br />
results that is displayed on the<br />
page.<br />
• l<strong>as</strong>t — Ordinal number<br />
of the l<strong>as</strong>t group with search<br />
results that is displayed on the<br />
page.<br />
None.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
17<br />
Tags for the results<br />
block<br />
categ<br />
Description<br />
Identifying data about a group of found documents.<br />
Attributes<br />
• attr — For service use. Must<br />
match the value p<strong>as</strong>sed in the<br />
request.<br />
• name — Unique group ID.<br />
doccount<br />
Approximation of the number of documents that are used<br />
for forming the group.<br />
Documents that potentially may be included in the group<br />
are ranked according to the request conditions (the<br />
sortby parameter). Depending on the value of the docs-ingroup<br />
parameter, from one to three of the first documents<br />
are included in the group.<br />
None.<br />
relevance For service use. priority — For service use.<br />
doc<br />
Grouping.<br />
Each doc tag contains information about a found document.<br />
name — Unique ID of a found<br />
document.<br />
Depending on the value of the docs-in-group parameter, each<br />
group can contain from one to three of the doc grouping tags.<br />
url Address of a found document. None.<br />
domain The domain that the found document is in. None.<br />
title<br />
Title of the found document.<br />
Words that are in the search query are highlighted with<br />
the hlword tag.<br />
None.<br />
headline<br />
modtime<br />
Optional. Document summary.<br />
It is created using the HTML meta tag containing<br />
the name attribute with the “description” value.<br />
Date and time the document w<strong>as</strong> changed, in the format:<br />
Т<br />
None.<br />
None.<br />
size Size of the found document, in bytes. None.<br />
charset Encoding of the found document. None.<br />
p<strong>as</strong>sages Grouping tag that contains a list of document p<strong>as</strong>sages. None.<br />
p<strong>as</strong>sage<br />
P<strong>as</strong>sage with the document summary.<br />
Words that are in the search query are highlighted with<br />
the hlword tag.<br />
The maximum number of p<strong>as</strong>sages to be p<strong>as</strong>sed in a single<br />
p<strong>as</strong>sages tag is defined by the value of the<br />
maxp<strong>as</strong>sages parameter for the search request.<br />
None.<br />
mime-type The document type in accordance with RFC2046. None.<br />
properties Grouping tag that contains document properties. None.<br />
_P<strong>as</strong>sagesType<br />
P<strong>as</strong>sage type. Possible values:<br />
• “0” — Standard p<strong>as</strong>sage (created from the document<br />
text).<br />
• “1” — P<strong>as</strong>sage b<strong>as</strong>ed on the link text. It is used if the<br />
document w<strong>as</strong> found via a link.<br />
None.<br />
lang<br />
Optional.<br />
Document language.<br />
None.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
18<br />
Tags for the results<br />
block<br />
Description<br />
saved-copy-url Address of a saved copy of the document. None.<br />
Attributes<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
19<br />
Request for limits for the next day<br />
Returns information about restrictions on the number of queries that can be sent each hour.<br />
The response contains information for each hour in the next 24 hours.<br />
Note:<br />
Hourly limits are only applied to the “russian” type of search.<br />
Request format<br />
http://xmlsearch.yandex./xmlsearch action=limits-info<br />
& user=<br />
& key=<br />
user<br />
key<br />
User name. Must match the login for <strong>Yandex</strong>.P<strong>as</strong>sport that w<strong>as</strong> set during registration.<br />
Value of the <strong>API</strong> key that w<strong>as</strong> issued during registration.<br />
Sample request<br />
This request returns information about hourly limits restricting the number of search queries that can be sent by the “xmlsearch-user”<br />
user during the next 24 hours:<br />
http://xmlsearch.yandex.ru/xmlsearchaction=limits-info&user=xml-searchuser&key=03.44583456:c876e1b098gh65khg834ggg1jk4ll9j8<br />
Response format<br />
In response to a request for hourly limits, <strong>Yandex</strong>.XML returns an XML file in UTF-8 encoding.<br />
Note:<br />
• If the allowed number of queries in one of the hours is exceeded, the excess queries are subtracted from<br />
the same hour the next day. These excesses are calculated when generating the response.<br />
• Hourly limits are only applied to the “russian” type of search. For the other types of search, the service<br />
returns information for each hour about the daily limits on the allowed number of queries.<br />
Below you will find the general structure of a resulting XML document with sample values.<br />
<br />
<br />
<br />
500<br />
450<br />
590<br />
600<br />
300<br />
200<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
20<br />
500<br />
500<br />
500<br />
100<br />
100<br />
100<br />
100<br />
200<br />
300<br />
300<br />
300<br />
300<br />
300<br />
300<br />
400<br />
500<br />
500<br />
600<br />
<br />
<br />
<br />
Tag Description Attributes<br />
response Grouping. None.<br />
limits<br />
time-interval<br />
Grouping.<br />
Contains entries about hourly limits on the allowed number<br />
of search queries.<br />
The number of search queries that can be sent during<br />
the specified time interval.<br />
The borders of the time interval are defined by attributes.<br />
None.<br />
• from — date and time<br />
(inclusively) of the start of the<br />
time interval the limit applies<br />
to.<br />
• to — date and time (not<br />
inclusively) of the end of<br />
the time interval the limit<br />
applies to.<br />
Data format in attributes:<br />
YYYY-MM-DD HH:MM:SS +HHMM<br />
“HHMM” specifies the event offset<br />
relative to UTC0.<br />
Attention!<br />
At this time, information about<br />
hourly limits is output for UTC0.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
21<br />
Formatting results<br />
When formatting search results, you must adhere to the rules described in the License for use of the <strong>Yandex</strong>.XML<br />
service. The license differs for Russian, Turkish, and Worldwide search types.<br />
Every page generated using <strong>Yandex</strong>.XML must contain:<br />
• A link to the <strong>Yandex</strong> home page, formatted <strong>as</strong> a logo.<br />
• Text with information about the number of documents found (“NNN pages found”). The information about<br />
the number of documents found is p<strong>as</strong>sed in the found-docs-human tag in the XML file with search<br />
results.<br />
The links to logos that must be used depending on the background color, along with formatting examples,<br />
are provided in the table below.<br />
Background color Logo Formatting example<br />
Black/dark<br />
Download.<br />
White font and a red letter “Y”.<br />
Transparent background.<br />
Red<br />
White/light<br />
Download.<br />
White font. Transparent background.<br />
Download.<br />
Black font and a red letter “Y”.<br />
Transparent background.<br />
Protection from robots<br />
Search queries can be submitted not only by users, but by robots, <strong>as</strong> well. When there is a flood of queries from<br />
robots, you may exceed the limitations applied for usage of the <strong>Yandex</strong>.XML.<br />
To prevent unauthorized access to the search by robots, a security algorithm is used. If it is suspected that a query<br />
w<strong>as</strong> submitted by a robot, a CAPTCHA is returned instead of search results (see this Wikipedia article about<br />
CAPTCHA).<br />
To use the algorithm for protection from robots, the partner must p<strong>as</strong>s information about the IP address and the<br />
"spravka" cookie for the request's author. The "spravka" cookie is generated on the <strong>Yandex</strong>.XML side and is<br />
returned the first time the user accesses search results. In the value that is received, the partner must replace<br />
the domain with his own, and then add the following string to the search response:<br />
Set-Cookie: spravka=...<br />
Information about the IP address and the "spravka" cookie are p<strong>as</strong>sed in the request header in the format:<br />
X-Real-Ip: 99.999.999.99<br />
Cookie: spravka=<br />
The diagram below illustrates the steps performed for protection from robots.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
22<br />
1. The user sends a query to the <strong>Yandex</strong>.XML partner.<br />
2. The search query is sent to the <strong>Yandex</strong>.XML service. The request must match the specified format.<br />
3. <strong>Yandex</strong>.XML initiates the algorithm for protection from robots. The values of the IP address and "spravka"<br />
cookie (if previously issued) are used for verification.<br />
Possible results of verification:<br />
• The request w<strong>as</strong> probably not sent by a robot. The process continues to step 13.<br />
• The request w<strong>as</strong> probably sent by a robot. The decision is made to display a CAPTCHA.<br />
4. <strong>Yandex</strong>.XML returns the partner an XML file in the following format:<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Developer's guide<br />
23<br />
<br />
<br />
<br />
Robot request<br />
<br />
http://captcha.image.gif<br />
CAPTCHA ID number<br />
Status<br />
<br />
5. The user is returned a page containing a CAPTCHA.<br />
6. The user sends the CAPTCHA value to the partner.<br />
7. The partner sends the CAPTCHA value obtained from the user via a GET request in the following format:<br />
http://xmlsearch.yandex.ru/xcheckcaptchakey=&rep=<br />
8. The value received is checked by the <strong>Yandex</strong>.XML service. If the CAPTCHA value w<strong>as</strong> entered incorrectly,<br />
the process continues to step 4. In addition, the captcha-status parameter is p<strong>as</strong>sed with the value<br />
“failed”.<br />
9. If the CAPTCHA value w<strong>as</strong> entered correctly, <strong>Yandex</strong>.XML issues the user a "spravka" cookie and p<strong>as</strong>ses<br />
it to the partner in the header with the following format:<br />
HTTP/1.1 200 OK<br />
Set-Cookie: spravka=<br />
If the request p<strong>as</strong>sed to <strong>Yandex</strong>.XML in step 1 w<strong>as</strong> saved successfully, the process continues to step 12.<br />
10. The partner lets the user enter a query.<br />
11. The user sends a query to the <strong>Yandex</strong>.XML partner.<br />
12. The search query is sent to the <strong>Yandex</strong>.XML service. Along with the request, the user's IP address<br />
and "spravka" cookie are p<strong>as</strong>sed.<br />
13. <strong>Yandex</strong>.XML processes the search query and generates results.<br />
14. An XML file with search results is returned to the partner.<br />
15. The partner returns the processed response to the user. If in step 9 the <strong>Yandex</strong>.XML issued a "spravka"<br />
cookie, it is saved on the user's computer.<br />
Tip:<br />
To try out how this flow works, use this script.<br />
Verifying correct CAPTCHA display<br />
To get familiar with the response format returned by <strong>Yandex</strong>.XML when a CAPTCHA is displayed, send<br />
a request (the value of the query parameter of the search request) with the following string:<br />
“e48a2b93de1740f48f6de0d45dc4192a”.<br />
The following GET request can be used by the user “xml-search-user” for reviewing the response format returned when<br />
a CAPTCHA is displayed:<br />
wget -q --header="X-Real-Ip: 127.0.0.1" -SO- 'http://xmlsearch.yandex.ru/xmlsearch<br />
user=xml-searchuser&key=03.44583456:c876e1b098gh65khg834ggg1jk4ll9j8&query=e48a2b93de1740f48f6de0d45dc4<br />
192a&showmecaptcha=yes'<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
24<br />
Questions and answers<br />
This section answers some common questions that <strong>Yandex</strong>.XML users <strong>as</strong>k. For convenience, questions<br />
are grouped in categories:<br />
• What is XSLT<br />
• Notifications.<br />
• IP address.<br />
• Additional search features.<br />
• Encoding.<br />
What is XSLT<br />
XSLT is a language for converting and rendering XML documents and is a part of the set of<br />
XSL recommendations.<br />
Detailed information about the XSLT language is provided in the following documents:<br />
• Extensible Stylesheet Language (XSL).<br />
• XSL Transformations (XSLT).<br />
Notifications<br />
What are notifications<br />
Notifications are a service for automatically sending email when problems arise during use of <strong>Yandex</strong>.XML.<br />
The email address, settings for sending notifications, and thresholds are all set during registration.<br />
What should I do if I get a notification that the number of requests<br />
h<strong>as</strong> sharply decre<strong>as</strong>ed<br />
The table below shows possible re<strong>as</strong>ons for a decre<strong>as</strong>ed number of requests, how to diagnose it, and<br />
recommended solutions.<br />
Re<strong>as</strong>on Diagnostic methods Recommended solutions<br />
Decre<strong>as</strong>ed number of searches<br />
performed. For example, this<br />
may occur due to natural variation in the<br />
number of visitors depending on the<br />
day of the week or the time of day.<br />
Unavailability or partial availability<br />
of <strong>Yandex</strong>.XML on the web site.<br />
Review the site usage statistics for days<br />
of the week and time of day.<br />
Try submitting several search queries<br />
yourself. Check the accuracy of the<br />
results that are returned.<br />
Incre<strong>as</strong>e the notification threshold on the<br />
Settings page.<br />
Check whether the request format<br />
is correct.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
25<br />
What should I do if I get a notification that the number of requests<br />
h<strong>as</strong> sharply incre<strong>as</strong>ed<br />
The table below shows possible re<strong>as</strong>ons for an incre<strong>as</strong>ed number of queries, how to diagnose it, and<br />
recommended solutions.<br />
Re<strong>as</strong>on Diagnostic methods Recommended solutions<br />
Incre<strong>as</strong>ed number of searches<br />
performed. For example, this<br />
may occur due to natural variation in the<br />
number of visitors depending on the<br />
day of the week or the time of day.<br />
Review the site usage statistics for days<br />
of the week and time of day.<br />
Incre<strong>as</strong>e the notification threshold on the<br />
Settings page.<br />
DoS attack.<br />
Check the server log files for data<br />
suggesting a DoS attack.<br />
What should I do if I get a notification that there were no requests<br />
for a 24-hour period<br />
Check how the search is working on the site.<br />
If statistics show a sharp decre<strong>as</strong>e in the number of queries made from the site, it is possible that this is due to the<br />
search not working correctly.<br />
What should I do if I get a notification that the number of requests<br />
is approaching the daily limit<br />
Review the restrictions applied to the service and ways to get around them. Contact a <strong>Yandex</strong> representative<br />
to discuss details of expanding search features.<br />
IP address<br />
Why is an IP address required for registration<br />
The IP address, in combination with a <strong>Yandex</strong>.P<strong>as</strong>sport account, is used for identifying a <strong>Yandex</strong>.XML user.<br />
The results of user identification determine the restrictions applied to service usage.<br />
How do I find out what my IP address is<br />
The way to determine the IP address depends on the type of computer being used to access the <strong>Yandex</strong>.XML<br />
service.<br />
Device type<br />
Server<br />
Possible methods for detecting the IP address<br />
• Ask your provider for the IP address.<br />
• Set up a remote connection to the server and run the ipconfig command (Windows)<br />
or ifconfig (Unix).<br />
• Run the ping command from the command line of a personal computer.<br />
Personal computer<br />
• Use the <strong>Yandex</strong>.Internetometer service.<br />
• If static addresses are used, <strong>as</strong>k your service provider.<br />
Note:<br />
Note that if a modem is used, the IP address can change each time a connection is made.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
26<br />
The IP address being registered is in use<br />
The table below shows possible re<strong>as</strong>ons and solutions.<br />
Re<strong>as</strong>on<br />
An open proxy server is being used<br />
to access <strong>Yandex</strong>.XML.<br />
A modem is being used to access<br />
the Internet.<br />
The service is being accessed from<br />
a server.<br />
Possible solution<br />
User your Internet provider's proxy server.<br />
Your provider <strong>as</strong>signs a dynamic IP address, which can change each time<br />
you connect. Try disconnecting and reconnecting to the Internet.<br />
Obtain a dedicated IP address.<br />
Additional search features<br />
Setting up site search<br />
To restrict the search to the web site only, use the host operator.<br />
Syntax:<br />
host:<br />
The following request is used for searching for the phr<strong>as</strong>e “search settings” on the web site http://help.yandex.ru/:<br />
search settings host:help.yandex.ru<br />
Restricting the search to a region or category<br />
To restrict the search to documents that are relevant to a particular region or category, use the cat operator.<br />
Syntax:<br />
cat:<br />
For the value of the cat operator, p<strong>as</strong>s the adjusted value of the region ID (added to “11000000”) or category<br />
ID (added to “9000000”).<br />
For a category, you may also use a search theme (see the section Creating and changing themes in the Help<br />
for the <strong>Yandex</strong>.Search for sites service). In this c<strong>as</strong>e, the value of the ID obtained when creating a theme should<br />
be p<strong>as</strong>sed in unaltered form (do not adjust it).<br />
The request may specify multiple regions and categories. To do this, use the logical operators “AND”<br />
(“&&”) and “OR” (“|”).<br />
The following request is used for searching for the word “meat” in documents that are relevant to the category “bodybuilding<br />
nutrition” (ID “3783”) in the city of “Samara” (ID “51”):<br />
meat cat:11000051 && cat:9003783<br />
Search in results<br />
To set up a search in results, use the && operator.<br />
Syntax:<br />
() && ()<br />
The following request is used to search for documents with the phr<strong>as</strong>e “manual transmission” in results for the query<br />
“autos”:<br />
(autos) && (manual transmission)<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
27<br />
Encoding<br />
How to correctly set encoding for a request being sent<br />
The request encoding is set in the header of the XML file:<br />
<br />
Which encoding is used for sending the search response<br />
The XML file with search results is sent in UTF-8 encoding. To convert it to a different encoding, you can use a<br />
library such <strong>as</strong> the libiconv library or the Convert::Cyrillic module.<br />
Incorrect characters in the response<br />
In most c<strong>as</strong>es, incorrect characters in the response are the result of sending the request at the socket level.<br />
Possible solutions:<br />
• Use HTTP version 1.0 instead of 1.1.<br />
• Use a higher-level type of interface.<br />
• Configure handling for chunked responses.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Appendices<br />
28<br />
Appendices<br />
Validating XML files<br />
To prevent incorrect processing of search queries, at the testing stage we strongly recommend validating<br />
XML files that are generated for requests using the POST method.<br />
You can validate XML files in the <strong>Yandex</strong>.Webm<strong>as</strong>ter service. For validation, the XML request schema is used.<br />
To validate a file, follow these steps:<br />
1. Open the XML-feed validator page.<br />
2. Select other schem<strong>as</strong> → link in the Standard validation schema group.<br />
3. Set the value “http://api.yandex.tr/xml/doc/dg/res/request.en.xs” in the Specify the link to your<br />
XSD schema box.<br />
4. Set one of the ways to p<strong>as</strong>s the contents of the XML document in the Feed for validation box.<br />
5. Click the Check button.<br />
If the XML file complies with the schema, the message “XML complies with the XSD schema” is returned.<br />
If inconsistencies are discovered, it returns information about the line where you should look for an error.<br />
Error codes<br />
When search requests are processed incorrectly, the server response contains the error tag.<br />
Format:<br />
<br />
Error description text<br />
The table below lists codes and descriptions for common errors that occur when processing search requests.<br />
Error code<br />
Description<br />
1 The query text (the value p<strong>as</strong>sed in the query element) contains a syntactical error.<br />
For example, a query w<strong>as</strong> sent that contained only two sl<strong>as</strong>h symbols in a row (“//”).<br />
2 An empty search query w<strong>as</strong> defined (an empty value w<strong>as</strong> p<strong>as</strong>sed in the query element).<br />
15 There are no search results for the specified search query.<br />
18 The XML file cannot be validated, or invalid request parameters are set. Possible re<strong>as</strong>ons:<br />
• Incorrect tags or tag values were p<strong>as</strong>sed.<br />
• The request body contains non-escaped special characters. For example, the ampersand<br />
symbol (“&”), and so on.<br />
• The request page contains search results with more than 1000 entries. For example, if each<br />
page contains 10 results, this error will be returned when attempting to request page 101 and<br />
further in results.<br />
19 The search query contains incompatible parameters (for example, incompatible values for the<br />
groupings element).<br />
20 The re<strong>as</strong>on for the error is unknown. If the error persists, contact the support service.<br />
31 The user is not registered on the service.<br />
32 Limit exceeded for the number of queries allowed per day. Review the information about<br />
restrictions and choose a suitable method for incre<strong>as</strong>ing your daily quota.<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
Appendices<br />
29<br />
Error code<br />
Description<br />
33 The IP address that the search request w<strong>as</strong> sent from does not match the one(s) set during<br />
registration.<br />
34 The user is not registered in <strong>Yandex</strong>.P<strong>as</strong>sport.<br />
37 Error in request parameters. Maybe mandatory parameters were omitted, or mutually exclusive<br />
parameters were defined.<br />
42 The key that w<strong>as</strong> issued during registration contains an error. Check whether the correct address<br />
is used for sending requests.<br />
43 The version of the key that w<strong>as</strong> issued during registration contains an error. Check whether<br />
the correct address is used for sending requests.<br />
44 The address that requests are sent to is no longer supported. Correct the value to match<br />
the address that w<strong>as</strong> given during registration.<br />
48 The search type that w<strong>as</strong> specified during registration does not match the search type that is being<br />
used for requesting data. Reset the domain that is being used to the correct domain. For corrections,<br />
use the URL for sending requests.<br />
100 The request w<strong>as</strong> most likely sent by a robot. When this error appears, a CAPTCHA must be returned<br />
to the user.<br />
Search regions<br />
The region to give preference to when generating search results is defined by the value of the lr parameter<br />
of the search query. Countries, federal subjects, and cities can be specified <strong>as</strong> the region.<br />
A list of IDs for commonly used regions of Turkey is provided in the table below.<br />
ID<br />
Region<br />
11503 Ankara<br />
11508 Istanbul<br />
11505 Izmir<br />
11504 Bursa<br />
11501 Adana<br />
115011 Antalya<br />
A list of IDs for commonly used countries is provided in the table below.<br />
ID<br />
Country<br />
225 Russia<br />
187 Ukraine<br />
149 Belarus<br />
159 Kazakhstan<br />
See also<br />
Other popular regions<br />
<strong>Yandex</strong>.XML<br />
Developer's guide
<strong>Yandex</strong>.XML<br />
Developer's guide<br />
16.10.2014