SDK overview
This page explains what the SDK is for today. For setup, see Install the SDK; for the first calls, see the SDK quick start; for every class and method, see the SDK API reference.
@alternatefutures/sdk (0.2.x) is a TypeScript client for the Alternate
Clouds GraphQL API, with Node.js and browser builds. It predates the compute
platform: it was written for an earlier product, and only part of it maps onto
the API that runs today.
What works against the current API
| Area | Client | Use it for |
|---|---|---|
| Authentication | PersonalAccessTokenService | Exchange a personal access token for a session, scoped to a project |
| Projects | sdk.projects() | list(), create({ name }) |
| Access tokens | sdk.user() | listPersonalAccessTokens() |
| Functions | sdk.functions() | list, get, create, update, deploy, delete |
What the SDK does not cover
Services, deployments, templates, regions, logs, custom domains, and billing
have no SDK client. For those, use the acc CLI (every command works
non-interactively with AF_TOKEN, AF_PROJECT_ID, and -y), the
web app, or the GraphQL API directly at
https://api.alternatefutures.ai/graphql with a personal access token as a
bearer token.
Legacy clients: do not build on these
Present in the package, not backed by the current API
sdk.sites(), sdk.storage(), sdk.ipfs(), sdk.ipns(), sdk.ens(),
sdk.privateGateways(), and sdk.applications() come from the retired
hosting product. Against the current API their calls fail validation, hit
fields that no longer exist, or return empty lists. sdk.domains() is that
product's domain and zone client and is not verified against today's API;
custom domains for services are not available yet (the old guide is
archived). All of these
remain in the package and in the API reference for compatibility
only.
ApplicationAccessTokenService and StaticAccessTokenService are also
legacy: the first talks to a retired service, the second only carries a token
you obtained elsewhere.
Two rules
- Import from the package root,
@alternatefutures/sdk, on Node too. The/nodeentry point in 0.2.4 fails to load; see Install the SDK. - No endpoint setup. 0.2.4 targets
https://api.alternatefutures.ai/graphqlby default. PassgraphqlServiceApiUrlto the SDK and to the token service only to reach another host.