SDKs

Usage

Both clients are generated from the OpenAPI document, default to https://api.threefold.eco, and raise a typed error that carries the API's code, whose_error, retryable and hint. Use a tf_test_… key to run them against fixture data in tests.

The TypeScript package (@threefold/client) and the Python package (threefold) are not on npm or PyPI yet. Until they are, the REST examples on this page do the same job with any HTTP client.

TypeScript

import { ThreefoldClient } from "@threefold/client";

const tf = new ThreefoldClient({ apiKey: process.env.THREEFOLD_API_KEY });

const comparison = await tf.compareMarkets({ from: "de", to: "jp", niche: "health-fitness" });
console.log(comparison.shared, comparison.localOnly);

Methods: libraryMeta, compareMarkets, searchApps, searchStore, topApps, getApp, marketBrief, b2bChecklist, searchPaidCreatives, searchOrganicPosts, trackApp, usage, plus get(path) and post(path, body) for any other route. Errors are ThreefoldError.

Python

from threefold import ThreefoldClient

with ThreefoldClient(api_key="tf_live_your_key") as tf:
    comparison = tf.compare_markets("de", "jp", "health-fitness")
    print(comparison["shared"])

Methods: library_meta, compare_markets, search_apps, search_store, top_apps, get_app, market_brief, b2b_checklist, search_paid_creatives, search_organic_posts, track_app, usage, plus get and post. Needs Python 3.9 or later; depends on httpx and pydantic.

Errors

Both clients turn an error response into a typed exception with the fields of the error body:

FieldTypeScript ThreefoldErrorPython ThreefoldError
Machine-readable codecodecode
Whose faultwhose_error (caller, upstream, threefold)whose_error
Safe to retryretryable (also true for 429 and 503)retryable
What to dohinthint
HTTP statusstatusstatus_code

Testing with a sandbox key

Create a tf_test_… key and point the client at it. Sandbox calls return fixture data, never call a supplier and are never charged, so they are safe in CI. The repository's own smoke tests run both clients this way.

const tf = new ThreefoldClient({ apiKey: process.env.THREEFOLD_TEST_KEY });
const meta = await tf.libraryMeta();

Anything else

Both clients expose get and post for routes without a helper method. The API reference lists every route.