NoClick
class NoClickConnection settings for the platform API. Most code never builds one: the
default client reads NOCLICK_API_KEY / NOCLICK_API_URL. Pass
{ client } to any method to use another account or endpoint.
| apiKey | string | ApiKeyProvider | undefined | |
| baseUrl | string | |
| timeoutMs | number | |
| maxRetries | number | |
| backoffMs | number | |
| maxBackoffMs | number | |
| inApp | boolean | Whether this client signs in as a deployed app's own code (its deployment's credential), where
|
forSessionstatic
static forSession(
session: string | { token: string; baseUrl?: string },
options?: Omit<ClientOptions, "apiKey">,
): NoClickA client that authenticates with a user session (a Session or its
nk_sess_... token): every call acts for the session's user with its
scopes. The same as new NoClick({ apiKey: token }).
Defaults to NOCLICK_API_URL, then https://api.noclick.com.
Per-attempt request timeout (default 60s).
Retries for 408/429/5xx (never a POST's 500, which is replayed) and network errors (default 3).
First backoff step; doubles per attempt with jitter (default 500ms).
A custom fetch (a proxy agent, a test double). Defaults to the global one.
A client for that session, on the session's own API endpoint unless you pass base_url.
request
request(method: string, path: string, options?: RequestOptions): Promise<T>Send one API call and return its decoded body. Writes carry an
Idempotency-Key reused on every retry, so a retried POST can't do the work twice.
undefined = the ambient user, null = the account.
Reused on every retry; generated for each write when omitted.
A raw body (bytes or text) instead of json.
"application/octet-stream"bytes returns a Uint8Array instead of decoded JSON.
The response's decoded JSON (None for an empty body), or its raw bytes with binary=True.
An error response raises its noclick.Error instead.
consoleUrl
consoleUrl(section: string, id: string): string | nullThe developer console page for an object (operations?op=, agents/, users/), or
null when this client doesn't talk to the hosted API.
The page's URL, or None when this client doesn't talk to the hosted API.
asUserTypeScript only
asUser(user: UserRef | null, fn: () => T | Promise<T>): Promise<T>Run fn acting for user; the same as the module-level asUser.
configure
function configure(options?: ClientOptions): NoClickReplace the default client, e.g. configure({ apiKey: "nk_live_..." }).
A key, or a function returning one per attempt (a refreshing token). Defaults to NOCLICK_API_KEY
(inside a deployed app without a key, its deployment's own credential, NOCLICK_DEPLOYMENT_TOKEN).
Defaults to NOCLICK_API_URL, then https://api.noclick.com.
Per-attempt request timeout (default 60s).
Retries for 408/429/5xx (never a POST's 500, which is replayed) and network errors (default 3).
First backoff step; doubles per attempt with jitter (default 500ms).
A custom fetch (a proxy agent, a test double). Defaults to the global one.
The new default client, which every call without client= now uses.
defaultClient
function defaultClient(): NoClickThe client used when no { client } is given (built from the environment).
The shared default client: the one configure last set, else one built from NOCLICK_API_KEY
and NOCLICK_API_URL.
VERSION
const VERSION: "0.2.0"This client's version.
DEFAULT_BASE_URL
const DEFAULT_BASE_URL: "https://api.noclick.com"The hosted API; NOCLICK_API_URL (or base_url=) points a client elsewhere.
CONSOLE_BASE_URL
const CONSOLE_BASE_URL: "https://noclick.com/dashboard/developers"Where the hosted API's objects are shown (only for the hosted base URL).