Skip to main content
GET
/
autocomplete
Autocomplete
curl --request GET \
  --url https://htsapi.com/v1/autocomplete \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://htsapi.com/v1/autocomplete"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://htsapi.com/v1/autocomplete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://htsapi.com/v1/autocomplete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://htsapi.com/v1/autocomplete"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://htsapi.com/v1/autocomplete")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://htsapi.com/v1/autocomplete")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "suggestions": [
    {
      "code": "<string>",
      "description": "<string>",
      "score": 123
    }
  ]
}
{
"error": "<string>",
"message": "<string>",
"retry_after": 123
}
Fast prefix search for UI typeahead. Returns suggestions based on code or description matches. Optimized for real-time search experiences.

Parameters

ParameterTypeRequiredDescription
qstringYesSearch query (min 2 chars, max 200 chars)
limitintegerNoMaximum number of results (default: 10, max: 20)

Example Request

curl -X GET "https://htsapi.com/v1/autocomplete?q=telephone&limit=10" \
  -H "Authorization: Bearer your_hts_api_key"

Example Response

{
  "suggestions": [
    {
      "code": "8517.12.00",
      "description": "Telephone sets, including telephones for cellular networks or for other wireless networks",
      "score": 95
    },
    {
      "code": "8517.11.00",
      "description": "Base stations",
      "score": 80
    },
    {
      "code": "8517.62.00",
      "description": "Machines for the reception, conversion and transmission or regeneration of voice, images or other data",
      "score": 75
    }
  ]
}

Behavior

  • Code queries: If the query starts with a number, searches by code prefix
  • Text queries: If the query starts with text, performs full-text search on descriptions
  • Scoring: Results are scored by relevance (higher is better)

Use Cases

  • Typeahead search boxes
  • Quick code lookup
  • Search suggestions
  • Real-time search experiences

Authorizations

Authorization
string
header
required

API key as Bearer token. Format: Bearer your_hts_api_key

Query Parameters

q
string
required

Search query (minimum 2 characters)

Required string length: 2 - 200
limit
integer
default:10

Maximum number of results (default: 10, max: 20)

Required range: 1 <= x <= 20

Response

Autocomplete suggestions

suggestions
object[]