Build an Autocomplete Search Box
Use the Suggest endpoints to power a search-as-you-type UI: send the current input as a prefix, show the matches, then follow the selected match straight to its news feed.
Step 1: Suggest entities by prefix
On each keystroke, send the current input as prefix. The response is an array of matches, each with a type (person, organization, location, brand, …) and a links.self pointing at its article feed.
curl "https://api.apitube.io/v1/suggest/entities?prefix=tesl&api_key=YOUR_API_KEY"import requests
response = requests.get(
"https://api.apitube.io/v1/suggest/entities",
params={
"prefix": "tesl",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())const params = new URLSearchParams({ "prefix": "tesl", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/suggest/entities?${params}`);
const data = await response.json();
console.log(data);$query = http_build_query(["prefix" => "tesl", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/suggest/entities?$query");
$data = json_decode($response, true);
print_r($data);package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/suggest/entities")
q := u.Query()
q.Set("prefix", "tesl")
q.Set("api_key", "YOUR_API_KEY")
u.RawQuery = q.Encode()
resp, _ := http.Get(u.String())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var data []map[string]any
json.Unmarshal(body, &data)
fmt.Println(data)
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.apitube.io/v1/suggest/entities?prefix=tesl&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/suggest/entities?prefix=tesl
Read the API key from an environment variable (do not hardcode it), handle request
errors, and print the key fields of each result.
Docs: https://docs.apitube.io/platform/news-api/parametersA suggestion looks like this — render name and type, and keep links.self for the next step:
[
{
"id": "Q478214",
"name": "Tesla, Inc.",
"type": "organization",
"links": {
"self": "https://api.apitube.io/v1/news/entity/478214",
"wikipedia": "https://en.wikipedia.org/wiki/Tesla,_Inc.",
"wikidata": "https://www.wikidata.org/wiki/Q478214"
},
"metadata": {}
}
]Debounce on the client (e.g. wait ~150 ms after the last keystroke) so you suggest on settled input rather than on every character — fewer calls, the same result.
Step 2: Pivot to the entity's news feed
When the user picks a suggestion, follow its links.self — that is the entity feed for the chosen id. From here all the usual filters apply (published_at, language.code, sort.by, pagination).
curl "https://api.apitube.io/v1/news/entity/478214?sort.by=published_at&api_key=YOUR_API_KEY"import requests
response = requests.get(
"https://api.apitube.io/v1/news/entity/478214",
params={
"sort.by": "published_at",
"api_key": "YOUR_API_KEY",
},
)
print(response.json())const params = new URLSearchParams({ "sort.by": "published_at", "api_key": "YOUR_API_KEY" });
const response = await fetch(`https://api.apitube.io/v1/news/entity/478214?${params}`);
const data = await response.json();
console.log(data);$query = http_build_query(["sort.by" => "published_at", "api_key" => "YOUR_API_KEY"]);
$response = file_get_contents("https://api.apitube.io/v1/news/entity/478214?$query");
$data = json_decode($response, true);
print_r($data);package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
u, _ := url.Parse("https://api.apitube.io/v1/news/entity/478214")
q := u.Query()
q.Set("sort.by", "published_at")
q.Set("api_key", "YOUR_API_KEY")
u.RawQuery = q.Encode()
resp, _ := http.Get(u.String())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var data map[string]any
json.Unmarshal(body, &data)
fmt.Println(data)
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.apitube.io/v1/news/entity/478214?sort.by=published_at&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/news/entity/478214?sort.by=published_at
Read the API key from an environment variable (do not hardcode it), handle request
errors, and print the key fields of each result.
Docs: https://docs.apitube.io/platform/news-api/parametersSuggest other classifiers
The same prefix pattern works for the taxonomy filters, so you can build typeahead pickers for categories, topics, and industries too:
/v1/suggest/categories— category picker./v1/suggest/topics— topic picker./v1/suggest/industries— industry picker.
Each returns matches with an id you can drop straight into the corresponding /v1/news/everything filter (category.id, topic.id, industry.id).
Tip: the
prefixparameter requires at least one character — skip the call while the input is empty.