Creating the client
Usealphscan(settings?) to create the API client. Settings can be omitted (then env is used), or passed to override.
AlphscanSettings
| Field | Type | Description |
|---|---|---|
apiUrl | string | API base URL (e.g. https://api.alphscan.io). No trailing slash. |
version | string | Stage/version (e.g. "dev" | "prod"). Appended to apiUrl when set. |
apiKey | string | API key for authenticated requests (X-API-Key and Authorization: Bearer). |
alephiumNodeUrl | string | Alephium node URL. |
alephiumBackendUrl | string | Alephium backend URL. |
explorerUrl | string | Block explorer base URL. |
Environment variables
The SDK reads settings from the environment when you don’t pass them:| Env key | Maps to |
|---|---|
ALPHSCAN_API_URL | apiUrl |
ALPHSCAN_VERSION | version |
ALPHSCAN_API_KEY | apiKey |
ALPHIUM_NODE_URL | alephiumNodeUrl |
ALPHSCAN_ALEPHIUM_BACKEND_URL | alephiumBackendUrl |
ALPHSCAN_EXPLORER_URL | explorerUrl |
Helpers
getSettingsFromEnv()— returns a partialAlphscanSettingsfromprocess.env.resolveSettings(overrides?)— merges env with overrides (overrides win).getApiBaseUrl(settings)— returns the effective base URL (e.g.https://api.alphscan.ioorhttps://api.alphscan.io/dev).
AlphscanClientApi
The object returned byalphscan():
| Member | Type | Description |
|---|---|---|
tx(transactionId) | (id: string) => TxApi | Transaction-scoped API (normalized events). |
plan | PlanApi | List plans (public). |
keys | KeysApi | List/create keys (requires apiKey). |
payment | PaymentApi | Payment flow (requires apiKey). |
token | TokenApi | List tokens (public). |
request(method, path, body?) | <T>(method, path, body?) => Promise<T> | Raw request. |
keys or payment without an API key throws.
Deprecated
createAlphscanClient({ baseUrl }) — use alphscan({ apiUrl: baseUrl }) instead.
