npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@polygonlabs/spol-api-client

v1.0.1

Published

Typed REST client and TanStack Query options factories for the sPOL REST API

Readme

spol-api-client

Typed REST client and TanStack Query factories for the sPOL REST API, generated from @polygonlabs/spol-api-schemas.

The client is code-generated by @hey-api/openapi-ts with the @polygonlabs/zod-to-openapi-heyapi plugin, which imports the actual Zod schema values the backend validates against — not types re-derived from the spec. That's the point: codecs from @polygonlabs/zod-codecs round-trip end-to-end (a wei amount arrives as a string and reaches the caller as a bigint; lastUpdated arrives as an ISO string and reaches the caller as a Date), and there is no hand-maintained type layer to drift from the service.

Install

pnpm add @polygonlabs/spol-api-client

@tanstack/react-query and react are optional peer dependencies — only required if you import the ./query subpath.

Entry points

| Entry point | Contents | | ------------------------------------ | ---------------------------------------------------------------------------------------------------------- | | @polygonlabs/spol-api-client | The singleton client, one function per operation, response/input types, and the TransportError / ResponseValidationError classes with their is*Error guards. No React dependency. | | @polygonlabs/spol-api-client/factory | createClient / createConfig for explicit multi-instance use (SSR, multiple base URLs, custom fetch). | | @polygonlabs/spol-api-client/query | TanStack Query options factories (listTransactionsV1Options, getSummaryV1Options, …) plus useCursorPagination — a generic "page N of M with Previous / Next" hook over the v1 cursor envelope. Requires the React peer deps. |

Usage

Configure the base URL once at application entry:

import { client } from '@polygonlabs/spol-api-client';

client.setConfig({ baseUrl: 'https://lst-api.polygon.technology' });

Call an operation (codec fields already decoded — amountPol is a bigint):

import { listTransactionsV1, isTransportError, isResponseValidationError } from '@polygonlabs/spol-api-client';

const { data, error } = await listTransactionsV1({
  path: { network: 'mainnet' },
  query: { limit: 20, cursor, type: 'WITHDRAW' }
});

if (isTransportError(error)) {
  // request never reached the API — error.cause is the native fetch error
} else if (isResponseValidationError(error)) {
  // reached the API, body didn't match the schema — error.cause is the ZodError
} else if (error) {
  // typed operation error, full field access
}

Cursor pagination in React (windowed Previous / Next, each page independently cached):

import { useCursorPagination, listTransactionsV1Options } from '@polygonlabs/spol-api-client/query';

const page = useCursorPagination((cursor) =>
  listTransactionsV1Options({ path: { network: 'mainnet' }, query: { limit: 20, cursor } })
);
// page.items, page.pageIndex, page.totalPages, page.goNext(), page.goPrevious()

Regeneration

src/generated/ is committed and gated by codegen-drift-check — never hand-edit it. Regenerate from the schemas package with:

pnpm --filter @polygonlabs/spol-api-client run generate

Contract-first pattern and the plugin's guarantees: apps-team-ops/docs/best-practices/rest-api-clients-codegen.md.