complete method

Returns the most probable ending of the text and the end of word attribute.


CompleteResponse complete(string key, string q, string lang, int limit);

Input parameters

Input parameters can be passed either with an HTTP GET request (see the example) or with an HTTP POST request, where the parameters are passed in the body of the HTTP request.

Request example:

XML interface:

JSON interface:

JSONP interface (for the myCallback function):

Example of input parameters.

Parameter Type Description
key string API key. Get a free API key on this page.
lang string

The language of the text (for example, "en"). To get the list of languages, use the getLangs method.

q string

The text where the user's cursor is pointed.

The suggestion is based on the word that the cursor is pointing at plus the two preceding words, so it is enough to pass a text with three or four words.

limit int

The maximum number of rows returned (1 by default).


In the XML interface, returns the CompleteResponse structure containing the suggested text. For example:

<?xml version="1.0" encoding="utf-8"?>
<CompleteResponse endOfWord="false" pos="-2">

XML scheme elements in the response:

Element Description

The root element, which contains the text element.


  • endOfWord – End of word attribute (true/false).

    The method can return the "continuation" of the passed phrase and the endOfWord= true attribute at the same time. For example, for the "He" text it returns "Hello", as well as the end of word attribute.

  • pos – Position in the word for which the ending suggestion is returned. Position is counted from the last character in the query passed in the q element.

    Usually, pos has a negative value. For example, for the q="Alice in Wonderl" it will return pos=-4. If the query contains a complete phrase, the request may return a suggestion for the next word. In this case, the pos value is 0 (for example, if q = "Alice in ") or 1 (for example, if q = "Alice in").


Contains string elements with the most likely suggestions for the text.

If the method cannot "continue" the text, the element isn't returned.

Error codes
Code Value Description
ERR_OK 200

Operation was completed successfully.


API key is invalid.


API key is blocked.


The number of requests exceeded the daily limit (requests that use the getLangs method are also counted).


The amount of suggested text exceeded the daily limit (requests that use the getLangs method are also counted).


Exceeded the maximum text size (1000 characters).


The language isn't supported.

In the JSON interface, JavaScript objects are returned instead of XML elements. The objects have the same names and semantics as the XML elements:


In the JSONP interface, the same JavaScript objects are returned in a callback function (for example, myCallback):