Skip to content

Suggest Topics

The /v1/suggest/topics endpoint provides autocomplete functionality for searching topics by name prefix. It is useful for building filter interfaces: the returned id can be passed directly to the topic.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/topics

This endpoint returns a list of topics 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 topic objects with the following structure:

json
[
  {
    "id": 0,
    "name": "string",
    "links": {
      "self": "string"
    }
  }
]

Response Fields

FieldTypeDescription
idintegerTopic identifier. Use it directly in the topic.id filter.
namestringTopic name
links.selfstringURL to get news articles on this topic (/v1/news/topic/{id})

Request Examples

Using query parameter

shell
curl "https://api.apitube.io/v1/suggest/topics?prefix=election&api_key=YOUR_API_KEY"

Using header authentication

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

Using Bearer token

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

Response Example

json
[
  {
    "id": 5021,
    "name": "elections",
    "links": {
      "self": "https://api.apitube.io/v1/news/topic/5021"
    }
  }
]

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