AutoComplete

FREEMIUM
Par Omry | Mise à jour 8 days ago | Other
Popularité

0.2 / 10

Latence

88ms

Niveau de service

100%

Health Check

N/A

LISEZ-MOI

The AutoComplete API allows you to suggest as-you-type completion for users. The API takes a prefix and some optional parameters and returns a list of suggestions ordered by probability. The api might also suggest misspellings if the prefix is likely misspelt. The probability is based on occurrences of words and phrases in Wikipedia.

Example:
note - In the examples the headers of the request are missing. See the documentation page for the full request

Let’s assume a user has started to type “un”. So “un” is the query string and it is passed through the parameter s

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=un

And the response:
[
{
“misspell”: “false”,
“text”: “united”
},
{
“misspell”: “false”,
“text”: “united states”
},
{
“misspell”: “false”,
“text”: “under”
},
{
“misspell”: “false”,
“text”: “until”
},
{
“misspell”: “false”,
“text”: “university”
}
]

Here we see a list of suggestions with each having “misspell”: “false”. This means the suggestions do not contain misspellings suggestions.
We’ll get to that in a while.

If 5 suggestions are not enough we can use the “size” parameter which controls the number of suggestions returned. Minimum is 1, maximum is 20.

Let’s see:

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=un&size=7

and the response:
[
{
“misspell”: “false”,
“text”: “united”
},
{
“misspell”: “false”,
“text”: “united states”
},
{
“misspell”: “false”,
“text”: “under”
},
{
“misspell”: “false”,
“text”: “until”
},
{
“misspell”: “false”,
“text”: “university”
},
{
“misspell”: “false”,
“text”: “united states state”
},
{
“misspell”: “false”,
“text”: “unique”
}
]

Now there are 7 suggestions in the result.

Let’s get back to misspellings now:
We now assume a user has typed “unu” :

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=unu

And the response:
[
{
“misspell”: “false”,
“text”: “unusual”
},
{
“misspell”: “false”,
“text”: “unusually”
},
{
“misspell”: “false”,
“text”: “unused”
},
{
“misspell”: “true”,
“text”: “united”
},
{
“misspell”: “true”,
“text”: “united states”
}
]

Now the first 3 suggestions have “misspell”: “false” but the last two have “misspell”: “true”. This means they contain spelling corrections. The API “thinks” it is likely the user wanted to type “uni”

You can turn this feature off by using the parameter misspell=false

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=unu&misspell=false

And the response:

[
{
“misspell”: “false”,
“text”: “unusual”
},
{
“misspell”: “false”,
“text”: “unusually”
},
{
“misspell”: “false”,
“text”: “unused”
},
{
“misspell”: “false”,
“text”: “unusable”
},
{
“misspell”: “false”,
“text”: “unusual feature”
}
]

Now there are no misspelling suggestions in result.

The priority misspellings are given can be controlled with the parameter misspell_sensitivity. The higher it is, the higher priority misspellings are given.

The last parameter is max_words. Using this parameter we can control the maximum number of words in the suggestion. The reason for this is that by default the API will try to guess if the user will type more words after this one. As an example let’s look back at the first request we used:

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=un

One of the suggestions was “united states”. If you want to limit the number of words returned you can use max_words.

curl ‘https://omrivolk-autocomplete-v1.p.mashape.com/complete?s=un%max_words=1

And the response:

[
{
“misspell”: “false”,
“text”: “united”
},
{
“misspell”: “false”,
“text”: “under”
},
{
“misspell”: “false”,
“text”: “until”
},
{
“misspell”: “false”,
“text”: “university”
},
{
“misspell”: “false”,
“text”: “unique”
}
]

Now all the suggestions are made of only one word.

Thats it. You are ready.

Abonnés : 9
Créateur d'API :
Rapid account: Omry
Omry
omryk
Connectez-vous pour évaluer l'API
Note : 1 - Votes : 1