Suggest Entities
The /v1/suggest/entities endpoint provides autocomplete functionality for searching entities by name prefix. This endpoint is useful for building search interfaces with entity suggestions.
To use the API, you'll require an API key. You can obtain an API key by signing up for an account on the APITube website.
Endpoint
GET /v1/suggest/entitiesThis endpoint returns a list of entities matching the provided name prefix. Results include entity details such as type, name, and links to external resources like Wikipedia and Wikidata.
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prefix | string | Yes | The name prefix to search for. Minimum 1 character. |
api_key | string | Yes* | Your API key. Can also be provided via headers. |
* Required if not provided in headers
Response Format
The endpoint returns an array of entity objects with the following structure:
json
[
{
"id": 0,
"name": "string",
"type": "string",
"links": {
"self": "string",
"wikipedia": "string",
"wikidata": "string"
},
"metadata": {}
}
]Entity Types
Entities can be one of the following types:
person- Individual peoplelocation- Geographic locationsorganization- Companies, institutions, and organizationsbrand- Commercial brandsproduct- Products and servicesnatural-disaster- Natural disasters and catastrophic eventsdisease- Diseases and medical conditionsevent- Notable eventssport- Sportsunknown- Type could not be determined
Response Fields
| Field | Type | Description |
|---|---|---|
id | integer | Unique identifier for the entity |
name | string | Name of the entity |
type | string | Type of entity (see Entity Types above) |
links.self | string | URL to get news articles about this entity |
links.wikipedia | string | Wikipedia page URL (if available) |
links.wikidata | string | Wikidata page URL (if available) |
metadata | object | Additional metadata about the entity (varies by entity type) |
Request Examples
Using query parameter
bash
curl "https://api.apitube.io/v1/suggest/entities?prefix=elon&api_key=YOUR_API_KEY"python
import requests
resp = requests.get(
"https://api.apitube.io/v1/suggest/entities",
params={"prefix": "elon", "api_key": "YOUR_API_KEY"},
)
print(resp.json())javascript
const params = new URLSearchParams({ prefix: "elon", api_key: "YOUR_API_KEY" });
const resp = await fetch(`https://api.apitube.io/v1/suggest/entities?${params}`);
console.log(await resp.json());php
$query = http_build_query(["prefix" => "elon", "api_key" => "YOUR_API_KEY"]);
$data = json_decode(file_get_contents("https://api.apitube.io/v1/suggest/entities?$query"), true);
print_r($data);go
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", "elon")
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)
}java
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=elon&api_key=YOUR_API_KEY"))
.GET()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}text
Write a script in your preferred language that calls the APITube News API:
GET https://api.apitube.io/v1/suggest/entities?prefix=elon
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/parametersUsing header authentication
shell
curl -H "X-API-Key: YOUR_API_KEY" \
"https://api.apitube.io/v1/suggest/entities?prefix=tesla"Using Bearer token
shell
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.apitube.io/v1/suggest/entities?prefix=apple"Response Example
json
[
{
"id": 123,
"name": "Apple Inc.",
"type": "organization",
"links": {
"self": "https://api.apitube.io/v1/news/entity/123",
"wikipedia": "https://en.wikipedia.org/wiki/Apple_Inc.",
"wikidata": "https://www.wikidata.org/wiki/Q312"
},
"metadata": {
"headquarters": {
"city": "Cupertino",
"country": "United States"
},
"founded": "1976",
"industry": "Technology"
}
},
{
"id": 500,
"name": "Apple",
"type": "product",
"links": {
"self": "https://api.apitube.io/v1/news/entity/500",
"wikipedia": "https://en.wikipedia.org/wiki/Apple",
"wikidata": "https://www.wikidata.org/wiki/Q89"
},
"metadata": {}
}
]Error Responses
Missing API Key
json
{
"errors": [
{
"code": "ER0200",
"message": "API key is required."
}
]
}Status Code: 400
Invalid API Key
json
{
"errors": [
{
"code": "ER0201",
"message": "API key not found."
}
]
}Status Code: 404
Missing Prefix Parameter
json
{
"errors": [
{
"code": "ER0248",
"message": "`Prefix` in query required."
}
]
}Status Code: 400