@polygonlabs/api-gateway-client
v2.1.1
Published
Type-safe REST client for the Polygon API Gateway
Keywords
Readme
@polygonlabs/api-gateway-client
Type-safe REST client for the Polygon API Gateway, generated with hey-api from the gateway's committed OpenAPI spec. Every response is validated at runtime with the same Zod schemas the server enforces.
Why this package exists
The client is generated from the same schema registry the gateway routes and
validates with (via
@polygonlabs/api-gateway-schemas),
so an API shape change ships as a new package version instead of a silent
break — and a response that doesn't match its schema fails loudly at the
validation boundary rather than corrupting state downstream.
Install
pnpm add @polygonlabs/api-gateway-clientUsage
import { client, screenAddress } from '@polygonlabs/api-gateway-client';
client.setConfig({ baseUrl: 'https://api-gateway.polygon.technology' });
const { data } = await screenAddress({
path: { address: '0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326' },
});
// data: { address, blocked, source: 'blocklist' | 'risk' }The screening endpoint accepts EVM (0x-hex), Solana (Base58), and Tron
(Base58Check) addresses.
Entry points
@polygonlabs/api-gateway-client— the fetch-based SDK: one function per API operation, the configurableclientsingleton, and the error-narrowing helpers (isResponseValidationError,isTransportError,isWrapperError).@polygonlabs/api-gateway-client/react— TanStack Query options factories for React apps. Requires the optionalreactand@tanstack/react-querypeer dependencies; the main entry works without them.@polygonlabs/api-gateway-client/factory— the underlying hey-api client factory, for constructing independently-configured client instances.
