Skip to main content

Official SDKs

Typed client libraries for the Host-Tracker REST API v2 in TypeScript, Python, Go and .NET - monitors, incidents, contacts, alerts, reports, status pages, instant checks and webhooks, without hand-rolling HTTP. The same surface is a shell away with ht-cli, the command-line client.

What the SDKs are

One contract, four languages, the same behaviour in each

Each client is generated from the same public OpenAPI document the running API publishes, so every documented operation is present and typed. On top of the generated surface sits a small hand-written layer that behaves identically in all four languages:

  • Bearer auth. Your API token on every request, nothing else to wire.
  • One error type. Every failure arrives as an RFC 9457 problem document with a machine-readable code - branch on that, not on the status alone (rate_limited and quota_exceeded are both 429).
  • Automatic idempotency. Every write carries a fresh Idempotency-Key, so a retried write replays the stored answer instead of doing the work twice.
  • Conservative retries. 429 rate_limited and a 503 carrying Retry-After are retried, honouring that header; quota_exceeded never is.
  • Cursor paging. A helper walks every page for you; the cursors stay opaque.
  • Job and instant-check polling. Bulk operations and on-demand checks are followed to completion at the pace the server asks for.
  • Webhook signature verification. Verify a delivery against your secret before you parse it.

You need an API token: mint one on the API page with the scopes the integration actually needs. The endpoint-by-endpoint reference is at /apidocs/v2 and the narrative documentation at /apidocs/v2/guide; the SDKs name every operation exactly as those pages do.

JavaScript / TypeScript

@hosttracker/sdk - ESM and CommonJS, types included, no dependencies

npm install @hosttracker/sdk
import { HostTracker } from '@hosttracker/sdk';

const ht = new HostTracker({ token: process.env.HT_TOKEN });

// Monitors that are down right now.
const page = await ht.monitors.listMonitor({ query: { limit: 10, state: ['down'] } });
console.log(page.data.length, 'monitors down');

// Start an instant check and wait for the locations to report.
const result = await ht.runCheck({ url: 'https://example.com', type: 'http' });
console.log(result.state, result.events?.length, 'locations reported');

Requires Node 20 or newer. Read calls work in a browser too.

Python

hosttracker - sync and async, typed end to end, built on httpx

pip install hosttracker
import os
from hosttracker import HostTracker

ht = HostTracker(token=os.environ["HT_TOKEN"])

page = ht.monitors.list_monitor(limit=50)
for monitor in page.data:
    print(monitor.name, monitor.state, monitor.url)

result = ht.run_check({"url": "https://example.com", "type": "http"})
print(result.state)

Requires Python 3.11 or newer. The same helpers are awaited on AsyncHostTracker.

Go

github.com/HostTracker/hosttracker-sdk-go - package hosttracker

go get github.com/HostTracker/hosttracker-sdk-go
c, err := hosttracker.New(os.Getenv("HT_TOKEN"))
if err != nil {
    log.Fatal(err)
}

resp, err := c.ListMonitorWithResponse(ctx, &hosttracker.ListMonitorParams{
    Limit: hosttracker.Ptr(int32(10)),
    State: &[]hosttracker.ListMonitorParamsState{"down"},
})
for _, m := range resp.JSON200.Data {
    fmt.Println(m.Id, *m.Name)
}

res, err := c.RunCheck(ctx, hosttracker.IcCreateRequest{
    Url:  "https://example.com",
    Type: hosttracker.Ptr(hosttracker.IcCreateRequestTypeHttp),
}, nil)
for _, ev := range *res.Events {
    fmt.Println(*ev.Location, ev.Error)
}

Requires Go 1.24 or newer. Every operation is a flat <OperationId>WithResponse(ctx, …) method on the client - no sub-clients to navigate.

.NET

HostTracker.Sdk - thread-safe, register the client as a singleton

dotnet add package HostTracker.Sdk
using HostTracker.Sdk;
using HostTracker.Sdk.Generated;

using var client = new HostTrackerClient(Environment.GetEnvironmentVariable("HT_TOKEN"));

var page = await client.Monitors.ListMonitorAsync(limit: 50);
foreach (var m in page.Data)
    Console.WriteLine($"{m.Name} - {m.State}");

var result = await client.RunCheckAsync(new IcCreateRequest { Url = "https://example.com", Type = "http" });
Console.WriteLine($"{result.State} with {result.Events?.Count ?? 0} location report(s)");

Requires .NET 8 (the package targets net8.0).

OpenAPI document

The contract the four clients are generated from

The API publishes its own description, and the same document is mirrored in the HostTracker/openapi repository together with an OpenAPI 3.0 twin for toolchains that do not read 3.1.

GET https://api2.host-tracker.com/openapi/v2.json

Working in a language we do not ship a client for? Point any OpenAPI generator at that document and get the whole surface typed, for example:

openapi-generator-cli generate -i https://api2.host-tracker.com/openapi/v2.json -g <your-language> -o ./hosttracker-client

A generated client gives you the operations and the schemas; the conventions the official SDKs implement for you - bearer auth, the problem-document error codes, idempotency keys, retries on Retry-After, cursor paging, job polling and webhook signatures - are written up in the API guides.

A Terraform provider is on the roadmap. Questions about an SDK or about ht-cli belong in its GitHub repository; account and billing matters go to support.