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

@blockscout/api-types

v12.0.4

Published

TypeScript types generated from Blockscout OpenAPI specs (public, private, and chain-specific)

Readme

@blockscout/api-types

TypeScript types generated from Blockscout OpenAPI specs via openapi-typescript:

  • shorthands (schemas, operations, paths) — the recommended entry point; flat lookups over the merged spec, spanning every chain type. See Usage
  • merged — every schema, path, and operation from all specs below combined into one namespace (for universal frontends that handle any chain type at runtime); see Merged schemas
  • publicApi — default public API (BlockScoutWeb.Specs.Public, no CHAIN_TYPE)
  • privateApi — account API (BlockScoutWeb.Specs.Private)
  • chain namespaces — chain-specific public API (CHAIN_TYPE set; matches generate-swagger.yml)

Build artifacts (openapi/, dist/) are gitignored; run npm run build after clone.

Prerequisites

  • Elixir / Mix at the Blockscout repo root (compiled block_scout_web app)
  • Node.js 18+ (for openapi-typescript)

Generate

From this directory:

npm install
npm run build

build runs:

  1. generate:spec — mix openapi.spec.yaml for public, private, and each chain type
  2. generate:types — openapi-typescript writes matching files under dist/

Usage

Shorthands (recommended)

Three top-level exports flatten the most common lookups against the merged spec, so you never index through components["schemas"] or ["responses"][200]["content"]["application/json"] by hand. Prefer these for everyday use:

import type { schemas, operations, paths } from "@blockscout/api-types";

// `schemas` — a model by name (merged across all chains; chain-specific props optional).
type Transaction = schemas["Transaction"];

// `operations` — keyed by short operationId, with `json` / `params` / `requestBody`.
type TxJson = operations["TransactionController.transaction"]["json"];
type TxParams = operations["TransactionController.transaction"]["params"];
type EthCallBody = operations["EthController.eth_call"]["requestBody"];

// `paths` — the 200 `application/json` body keyed by path, then HTTP method.
type Blocks = paths["/api/v2/blocks"]["get"];

Notes:

  • operationIds are shortened — the controller module prefix (BlockScoutWeb.API.V2., BlockScoutWeb.Account.API.V2., BlockScoutWeb.API.Legacy.) is stripped, so BlockScoutWeb.API.V2.TransactionController.transaction becomes TransactionController.transaction.
  • json is the 200 application/json response body; params is the request query/path parameters; requestBody is the application/json request body (never for endpoints without one).
  • paths only exposes the HTTP methods an endpoint actually defines; missing methods are absent, not never.
  • All three are derived from merged, so they already span every chain type. Reach for the merged/per-chain namespaces below only when you need something these don't cover (non-200 responses, response headers, raw path items).

Merged schemas

The shorthands above are built on the merged namespace — every schema, path, and operation from all specs combined, so a universal frontend can handle any chain type at runtime from a single type universe. Import merged directly when you need lookups the shorthands don't expose (non-200 responses, response headers, raw path items):

import type { merged } from "@blockscout/api-types";

// Includes the public base plus `arbitrum?`, `zksync?`, blob fields, etc. — all optional.
type Transaction = merged.components["schemas"]["Transaction"];

// Paths/operations are merged too, referencing the merged models:
type Tx = merged.paths["/api/v2/transactions/{transaction_hash_param}"]["get"]["responses"][200];

Per-spec namespaces

Types are also grouped by spec name in the package entry:

import type { publicApi, privateApi, arbitrum, optimismCelo } from "@blockscout/api-types";

type AddressResponse = publicApi.components["schemas"]["AddressResponse"];

type GetAddressParams =
  publicApi.paths["/api/v2/addresses/{address_hash_param}"]["get"]["parameters"];

type ArbitrumPath = arbitrum.paths[keyof arbitrum.paths];

publicApi / privateApi avoid TypeScript reserved words (public, private). optimism-celo is exported as optimismCelo (hyphen is invalid in identifiers)

Chain types

Synced with .github/workflows/generate-swagger.yml via scripts/chain-types.sh:

arbitrum, arc, blackfort, ethereum, filecoin, neon, optimism, optimism-celo, rsk, scroll, shibarium, stability, suave, zetachain, zilliqa, zksync

When CI adds or removes a chain type, update scripts/chain-types.sh and index.ts.

Schemas merging

scripts/merge-specs.mjs merges all generated specs (public → private → chains alphabetically) into openapi/merged.yaml, which compiles to dist/merged.schema.ts (exported as merged).

Merge semantics:

  • Schemas — properties are unioned; required is the intersection across specs defining a schema, so chain-specific properties are optional. Sub-objects defined in a single spec keep their required (e.g. arbitrum.gas_used_for_l1 stays required when arbitrum is present). enum values are unioned (e.g. transaction_types gains chain-specific entries).
  • Paths & operations — unioned across specs; chain-only endpoints (e.g. /v2/arbitrum/batches) are included. Shared operations are deep-merged, with parameters matched by (in, name) and their schemas unioned (e.g. enum query params gain chain-specific values). All operation $refs point at components.schemas, so they reference the merged models automatically.
  • Irreconcilable schema shapes (e.g. ethereum redefines Status as a beacon-deposit enum) become anyOf unions and are reported as warnings on stderr.