@axvn-hoding/api-types
v0.1.0
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:
- publicApi — default public API (
BlockScoutWeb.Specs.Public, noCHAIN_TYPE) - privateApi — account API (
BlockScoutWeb.Specs.Private) - chain namespaces — chain-specific public API (
CHAIN_TYPEset; matches generate-swagger.yml, excluding deprecated MUD)
Build artifacts (openapi/, dist/) are gitignored; run npm run build after clone.
Prerequisites
- Elixir / Mix at the Blockscout repo root (compiled
block_scout_webapp) - Node.js 18+ (for
openapi-typescript)
Generate
From this directory:
npm install
npm run buildbuild runs:
generate:spec—mix openapi.spec.yamlfor public, private, and each chain typegenerate:types—openapi-typescriptwrites matching files underdist/
Usage
Types are 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["/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).
Point your app at this package via file:../types-package or your monorepo workspace.
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.
