Skip to main content
For endpoints that don’t have a dedicated SDK method, use client.request(method, path, body?). It sends GET or POST with JSON and uses the client’s API key when set.

Signature

request<T>(method: "GET" | "POST", path: string, body?: object): Promise<T>
  • method: "GET" or "POST".
  • path: Path including query string (e.g. /chain/all?page=1&pageSize=20).
  • body: Optional object for POST (sent as JSON).
  • Returns: Parsed JSON as T.

Examples

const client = alphscan({ apiUrl: "https://api.alphscan.io", apiKey: "sk_..." });

const chains = await client.request<{ items: unknown[]; total: number }>(
  "GET",
  "/chain/all?page=1&pageSize=20"
);

const addresses = await client.request<{ items: unknown[]; total: number }>(
  "GET",
  "/addresses/all?page=1&pageSize=20"
);

const added = await client.request<{ name: string }>("POST", "/chain/add", {
  chainId: 123,
});

Query parameters

Build the path with URLSearchParams or template strings:
const page = 1;
const pageSize = 20;
const path = `/token/all?${new URLSearchParams({ page: String(page), pageSize: String(pageSize) })}`;
const data = await client.request("GET", path);

Errors

On non-2xx responses, request() throws with the response body text. Use try/catch to handle errors.