@blockfrost/openapi

中文文档
0.1.93发布于 2026/09/02TypeScriptCommonJS近 30 天下载 10.4万

OpenAPI specifications for blockfrost.io

原始使用文档
文档目录9 节
  1. Getting started
  2. Development
  3. Regenerating types
  4. Midnight GraphQL docs
  5. UI
  6. Dashboard API docs
  7. Usage
  8. Typescript example
  9. Rust crate

Blockfrost.io OpenAPI


Open Source OpenAPI specification for Blockfrost.io backend API.

GitHub master build ci npm version downloads

Getting started • Development

Getting started

The development version is available in the master branch.
The latest active release can be found under GitHub Releases.
For the published documentation, visit docs.blockfrost.io.

Development

Blockfrost OpenAPI blockfrost-openapi.yaml specification is generated from all yaml files in src directory. Then there is Mithril Aggregator API spec mithril.yaml which can be downloaded from Mithril Github. These two specs are then merged together via openapi-merge-cli (configuration is inside openapi-merge.json). Only the Mithril endpoints with a tag Cardano » Mithril are included into the final spec.

Tag Cardano » Mithril needs to be added manually to each relevant endpoint in Mithril OpenAPI spec.

If you add a new file then don't forget to add it to paths in src/definitions.yaml.

Edit the source yaml files and build the package:

yarn build

Regenerating types

TypeScript types (src/generated-types.ts) are regenerated as part of yarn build, or standalone with:

yarn generate-types

Rust types (the rust/ crate) are generated from the bundled openapi.yaml, so run yarn build (or at least yarn bundle) first if you have changed the source yaml files. The generation uses openapi-generator, which requires a Java runtime:

yarn generate-types:rust

If you don't have Java installed, use the Docker variant, which runs the same generator version inside a container:

yarn generate-types:rust:docker

The generator version is pinned in openapitools.json — when bumping it, update the image tag in the generate-types:rust:docker script to match.

Note that the Rust generation emits models only (apis=false), so spec changes that only touch endpoints or query parameters produce no changes in the crate.

Midnight GraphQL docs

The Midnight Indexer GraphQL API documentation is generated using SpectaQL from the schema file midnight-indexer-api.graphql. The SpectaQL configuration is in spectaql.yaml and the custom theme is in spectaql-theme/.

To update the GraphQL schema, download the version matching the deployed Midnight Indexer from the Midnight Indexer repository and replace the local file:

Then rebuild with yarn bundle (SpectaQL runs as part of the bundle step) to regenerate the docs in docs/midnight/.

Feel free to open PR against the master branch. It is a great place to start any discussion for new features and changes to the Blockfrost API.

UI

When you push a new commit, the documentation for your branch is automatically generated on Vercel and added to your PR as a deployment.

Dashboard API docs

The Blockfrost Dashboard API documentation at docs.blockfrost.io/dashboard-api/ is not built from this repo. Its OpenAPI spec and Scalar build live separately and deploy as their own Vercel project. This repo only owns the docs.blockfrost.io host and reverse-proxies /dashboard-api/* to that project via a rewrites rule in vercel.json — each service's spec and build pipeline stays in its own repo.

Usage

You can download openapi.yaml directly from the repository or use this project as a dependency in your JavaScript/TypeScript project.

Typescript example

Install @blockfrost/openapi:

yarn add @blockfrost/openapi

or

npm install @blockfrost/openapi

Now you can use TypeScript types generated from the OpenAPI specification:

import { components } from '@blockfrost/openapi';

type Block = components['schemas']['block_content'];
type Address = components['schemas']['address_content'];
type UtxoAsset = components['schemas']['address_utxo_content'];

Rust crate

Add blockfrost-openapi to your Cargo.toml:

[dependencies]
blockfrost-openapi = "0.1.87"

Now you can use the generated Rust types:

use blockfrost_openapi::models::{BlockContent, AddressContent, AddressUtxoContentInner};

版本与发布记录

@blockfrost/openapi 共发布 274 个版本,首次发布于 2021/02/17;过去 12 个月发布了 29 个版本。

版本发布日期距今
0.1.93latest2026/09/022 个月前
0.1.922026/08/212 个月前
0.1.912026/07/293 个月前
0.1.902026/06/234 个月前
0.1.90-beta.0beta2026/06/194 个月前
0.1.892026/06/085 个月前

关于 @blockfrost/openapi 的常见问题

@blockfrost/openapi 是什么?

OpenAPI specifications for blockfrost.io

如何安装 @blockfrost/openapi?

在项目目录运行 npm install @blockfrost/openapi,或使用 pnpm add / yarn add / bun add。

@blockfrost/openapi 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blockfrost/openapi 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@blockfrost/openapi 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blockfrost/openapi 可以商用吗?

@blockfrost/openapi 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@blockfrost/openapi 的下载量有多少?

根据 npm 官方下载统计,@blockfrost/openapi 在 2026/10/09 – 2026/11/07 这 30 天内被下载 103,577 次,日均约 3,453 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blockfrost/openapi 还在维护吗?

最新版本 0.1.93 发布于 2026/09/02(2 个月前);至今共发布 274 个版本,其中过去 12 个月发布了 29 个;首次发布于 2021/02/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。