Incorporating Autocomplete

To incorporate Autocomplete into your application, you first use a new parameter when you call the UID or IP Authenticate method. The new parameter for the Authenticate methods allows you to request an Autocomplete authentication token, endpoint, and necessary parameters. You can then use this information to make requests to the Autocomplete service from the browser to receive completed suggestions.

Call the Authenticate Method

Call an authenticate method with the Options parameter set to autocomplete. This produces a response with a token, endpoint, and necessary parameters for the Autocomplete service (ACS).

Example UI Authentication Request

{
    "userid":"user",
    "password":"pass",
    "InterfaceId":"wsapi",
    "Options":[ "autocomplete"]
}
<UIDAuthRequestMessage xmlns="http://www.ebscohost.com/services/public/AuthService/Response/2012/06/01" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <UserId>user</UserId>
  <Password>pass</Password>
  <InterfaceId>wsapi</InterfaceId>
  <Options>
    <Option>autocomplete</Option>
  </Options>
</UIDAuthRequestMessage>

Example IP Authentication Request

<IPAuthRequestMessage xmlns="http://www.ebscohost.com/services/public/AuthService/Response/2012/06/01" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
  <Options>
    <Option>autocomplete</Option>
  </Options>
</IPAuthRequestMessage> 

The response message will contain the Autocomplete URL and necessary parameters to make a call to the Autocomplete service. Similar to the EDS API Authentication token, the Autocomplete token will expire. The number of seconds that the token is valid for will be returned in the response in the tokentimeout field. The Auth token and Autocomplete token expire at the same time.

Example UIDAuth Response

<AuthResponseMessage>
  <AuthToken>bd320b75-18c5-489d-98c6-4bafeb834fbe</AuthToken>
  <AuthTimeout>1800</AuthTimeout>
  <Autocomplete>
    <Url>http://global.ac.ebsco-content.com/autocomplete/rest/autoComplete</Url>;
    <Token>ARD0AP0V5IkCXt9BS1gc0L4ztbkTXRcGiHy1OufcJQSxgttYu7oxyxAALLbc7/wYEQs=</Token>
    <TokenTimeout>1800</TokenTimeout>
    <CustId>s12345678</CustId>
  </Autocomplete>
</AuthResponseMessage>

Example IPAuth Response

<AuthResponseMessage>
  <AuthToken>bd320b75-18c5-489d-98c6-4bafeb834fbe</AuthToken>
  <AuthTimeout>1800</AuthTimeout>
  <Autocomplete>
    <Url>http://global.ac.ebsco-content.com/autocomplete/rest/autoComplete</Url>;
    <Token>ARD0AP0V5IkCXt9BS1gc0L4ztbkTXRcGiHy1OufcJQSxgttYu7oxyxAALLbc7/wYEQs=</Token>
    <TokenTimeout>1800</TokenTimeout>
    <CustId>s12345678</CustId>
  </Autocomplete>
</AuthResponseMessage>

If you do not have access to Autocomplete or the Autocomplete functionality is not available, you will receive an error message in the response.

Example Error Response

<AuthResponseMessage>
  <AuthToken>bd320b75-18c5-489d-98c6-4bafeb834fbe</AuthToken>
  <AuthTimeout>1800</AuthTimeout>
  <Autocomplete>
      <ErrorMessage>Autocomplete access is not available. Please contact EBSCO for additional information.</ErrorMessage>
  </Autocomplete>
</AuthResponseMessage>

Call the Autocomplete Service

Call the Autocomplete service to return the available completions in rank-descending order or an error message. To optimize performance of requests, requests must be done through the browser.

Autocomplete Parameters

Parameter NameDescriptionRequired/OptionalFormatExample Values
tokenThe authentication token that is returned from the Auth method when requesting the autocomplete option.Requiredhello
termThe user-entered prefix for autocompletion. It is typically found in the text input box.Requiredte
idxThe user-entered prefix for autocompletion. It is typically found in the text input box.RequiredUse holdings for title completion in PubFinder. Use rawqueries for completion of basic textual queries.rawqueries
filtersA JSON encoded key/value list indicating the filters to apply.RequiredA filter with name "custid" must be specified. custid has exactly one value. custid is the actual customer ID. This value will be returned from the Auth method.[{"name":"custid","values":["xxxxxxx"]}]
formatDetermines the format of the completion fragments.OptionalDefaults to html. One of html, json, or none.html

Autocomplete Request

The GET url is returned from the Authentication method call.

The request below returns the available completions for te.

Query Parameters

ParameterValue
tokenhello
termte
idxrawqueries
filters[{"name":"custid","values":["xxxxxxx"]}]

Use the Autocomplete URL that is returned from your authentication call to form the url.

Sample Autocomplete Request

GET http://Autocomplete01.ese.epnet.com:8080/Autocomplete/rest/Autocomplete?term=te&idx=rawqueries&filters=%5B%7B%22name%22%3A%22custid%22%2C%22values%22%3A%5B%22xxxxxxx%22%5D%7D%5D&token=hello

Example Autocomplete Response

If the request can be processed successfully, the response will contain the server-side processing time ("processingTime") and an array of completions ("terms"). Each completion consists of completed term(s) ("term") and a "score" (rank):

{
   "processingTime": 15,
   "terms":    [
            {
         "term": "Technology Review (MIT)",
         "score": 276722,
         "domain": "rawqueries",
      },
            {
         "term": "Teaching exceptional children",
         "score": 268236,
         "domain": "rawqueries",
      },
            {
         "term": "Texas Monthly",
         "score": 180412,
         "domain": "rawqueries",
      }
   ]
}