KontextNews

SDKs

Official client libraries for the KontextNews API: typed models, one method per endpoint, and X-API-Key auth built in.

Coming soon. The Tier 1 SDKs are built and tested against the live API, but are not published to the package registries yet. They ship at launch. Until then they are available from source in the repository under sdk/.

Languages

Pythonkontextnews - PyPI at launch
TypeScript / JavaScript@kontextnews/sdk - npm at launch
Gogithub.com/codexneuralis/kontextnews-sdk
PHPcodexneuralis/kontextnews-sdk - Packagist at launch

Quickstart

Every SDK reads the key from KONTEXT_API_KEY and returns typed objects. The same search in each language:

Python

import os
from kontextnews import ApiClient, Configuration
from kontextnews.api import SearchApi

cfg = Configuration(host="https://api.kontextnews.online")
cfg.api_key["ApiKeyAuth"] = os.environ["KONTEXT_API_KEY"]

for hit in SearchApi(ApiClient(cfg)).search(q="Nvidia", limit=5):
    print(hit.title, hit.rank)

TypeScript / JavaScript

import { Configuration, SearchApi } from "@kontextnews/sdk";

const config = new Configuration({
  basePath: "https://api.kontextnews.online",
  apiKey: () => process.env.KONTEXT_API_KEY!,
});

for (const hit of await new SearchApi(config).search({ q: "Nvidia", limit: 5 })) {
  console.log(hit.title, hit.rank);
}

Go

client := kontextnews.NewAPIClient(kontextnews.NewConfiguration())
ctx := context.WithValue(context.Background(), kontextnews.ContextAPIKeys,
    map[string]kontextnews.APIKey{"ApiKeyAuth": {Key: os.Getenv("KONTEXT_API_KEY")}})

hits, _, err := client.SearchAPI.Search(ctx).Q("Nvidia").Limit(5).Execute()
for _, h := range hits {
    fmt.Println(h.Title)
}

PHP

$config = KontextNews\Configuration::getDefaultConfiguration()
    ->setHost("https://api.kontextnews.online")
    ->setApiKey("X-API-Key", getenv("KONTEXT_API_KEY"));

$hits = (new KontextNews\Api\SearchApi(new GuzzleHttp\Client(), $config))
    ->search("Nvidia", limit: 5);
foreach ($hits as $h) {
    echo $h->getTitle(), PHP_EOL;
}
Auth: every request sends the key in X-API-Key. See Authentication for key handling and scopes.

Pagination and errors

List endpoints page with limit and offset, and return Link and X-Total-Count headers. The Python and TypeScript SDKs include an iterator example. Errors surface as typed exceptions with the status code. See Pagination and Errors.

Next: the full reference is in Endpoints, and the data shapes in Data model.