Autocompletes
Show me this endpoint for

About

The autocompletes endpoint a string of characters provided to it, and then returns suggested terms that are the most likely full words or strings. The terms returned by the News API are based on parameters the type parameters you can see below.

For example, if you provide the autocompletes endpoint with the term New York C and select the type dbpedia_resources, the API will return links to the DBpedia resources New_York_City, New_York_City_Subway, New_York_City_Police_Department, and so on.

Parameters

Name Type Description Notes
type String This parameter is used for defining the type of autocompletes. [enum: source_names, source_domains, entity_types, dbpedia_resources]
term String This parameter is used for finding autocomplete objects that contain the specified value.
language String This parameter is used for autocompletes whose language is the specified value. It supports ISO 639-1 language codes. [optional] [default to en] [enum: en, de, fr, it, es, pt]
perPage Integer This parameter is used for specifying number of items in each page. [optional] [default to 3]

Return type

Autocompletes

Example

import com.aylien.newsapi.*;
import com.aylien.newsapi.auth.*;
import com.aylien.newsapi.models.*;
import com.aylien.newsapi.parameters.*;
import com.aylien.newsapi.api.DefaultApi;

public class Main {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        // Configure API key authorization: app_id
        ApiKeyAuth app_id = (ApiKeyAuth) defaultClient.getAuthentication("app_id");
        app_id.setApiKey("YOUR_APP_ID");

        // Configure API key authorization: app_key
        ApiKeyAuth app_key = (ApiKeyAuth) defaultClient.getAuthentication("app_key");
        app_key.setApiKey("YOUR_APP_KEY");

        DefaultApi apiInstance = new DefaultApi();

        String type = "dbpedia_resources";
        String term = "obam";
        String language = "en";
        Integer perPage = 10;

        AutocompletesParams.Builder autocompletesBuilder = AutocompletesParams.newBuilder();

        autocompletesBuilder.setType(type);
        autocompletesBuilder.setTerm(term);
        autocompletesBuilder.setLanguage(language);
        autocompletesBuilder.setPerPage(perPage);

        try {
            Autocompletes result = apiInstance.listAutocompletes(autocompletesBuilder.build());
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#listAutocompletes");
            e.printStackTrace();
        }
    }
}