Skip to content

Suggest Categories ​

The /v1/suggest/categories endpoint provides autocomplete functionality for searching categories by name prefix. It is useful for building filter interfaces: the returned id can be passed directly to the category.id parameter of the news endpoints.

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/categories

This endpoint returns a list of categories matching the provided name prefix.

Query Parameters ​

ParameterTypeRequiredDescription
prefixstringYesThe name prefix to search for. Minimum 1 character.
api_keystringYes*Your API key. Can also be provided via headers.

* Required if not provided in headers

Response Format ​

The endpoint returns an array of category objects with the following structure:

json
[
  {
    "id": "medtop:15000000",
    "name": "string",
    "taxonomy": "string",
    "links": {
      "self": "string"
    }
  }
]

Response Fields ​

FieldTypeDescription
idstringCategory identifier — an IPTC Media Topic code such as medtop:15000000. Pass it verbatim to the category.id filter.
namestringCategory name
taxonomystringCategory taxonomy (e.g. iptc_mediatopics)
links.selfstringURL to get news articles in this category (/v1/news/category/{taxonomy}/{id})

Request Examples ​

Using query parameter ​

bash
curl "https://api.apitube.io/v1/suggest/categories?prefix=sport&api_key=YOUR_API_KEY"
python
import requests

resp = requests.get(
    "https://api.apitube.io/v1/suggest/categories",
    params={"prefix": "sport", "api_key": "YOUR_API_KEY"},
)
print(resp.json())
javascript
const params = new URLSearchParams({ prefix: "sport", api_key: "YOUR_API_KEY" });
const resp = await fetch(`https://api.apitube.io/v1/suggest/categories?${params}`);
console.log(await resp.json());
php
$query = http_build_query(["prefix" => "sport", "api_key" => "YOUR_API_KEY"]);
$data = json_decode(file_get_contents("https://api.apitube.io/v1/suggest/categories?$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/categories")
	q := u.Query()
	q.Set("prefix", "sport")
	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/categories?prefix=sport&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/categories?prefix=sport

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/everything

Using header authentication ​

shell
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.apitube.io/v1/suggest/categories?prefix=politic"

Using Bearer token ​

shell
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.apitube.io/v1/suggest/categories?prefix=econom"

Response Example ​

json
[
  {
    "id": "medtop:04000000",
    "name": "economy, business and finance",
    "taxonomy": "iptc_mediatopics",
    "links": {
      "self": "https://api.apitube.io/v1/news/category/iptc_mediatopics/medtop:04000000"
    }
  }
]

Error Responses ​

Missing or Invalid API Key ​

json
{
  "errors": [
    {
      "code": "ER0201",
      "message": "API key is required. Provide it via X-API-Key header or api_key query parameter."
    }
  ]
}

Status Code: 401

Missing Prefix Parameter ​

json
{
  "errors": [
    {
      "code": "ER0346",
      "message": "`Prefix` in query required."
    }
  ]
}

Status Code: 400