@across-protocol/acxv-api-schema

中文文档
0.1.0-master.46dc04e发布于 2026/11/05GPL-3.0零依赖近 30 天下载 6813

JSON Schema bundle and OpenAPI 3.1 document for the ACXV API.

原始使用文档
文档目录5 节
  1. Typed HTTP client
  2. Runtime validation
  3. Types without a client
  4. Rendered reference
  5. Reading the artifacts directly

ACXV API Schema

Machine-readable contract for the ACXV API, generated from the Rust types that implement it. Two artifacts ship together from the same commit, so they cannot disagree about the API they describe:

FileFormatCoversReach for it when you need
schema.jsonJSON Schema draft 2020-12every endpoint, including admin and diagnosticsruntime validation, event and WebSocket frame shapes
openapi.jsonOpenAPI 3.1public endpoints onlya typed HTTP client, rendered reference docs

openapi.json is derived from the same in-process bundle as schema.json, so every schema in it is plain draft 2020-12 — that is why the document targets 3.1 rather than 3.0, whose dialect cannot express these shapes. Endpoints marked x-internal in the bundle are absent from the OpenAPI document, along with the types only they use.

npm install @across-protocol/acxv-api-schema          # tracks master
npm install @across-protocol/acxv-api-schema@staging  # tracks staging

Every published version is 0.1.0-<channel>.<commit>. Pin the exact version if you need a contract that cannot move under you.

Typed HTTP client

openapi-fetch type-checks the path, method, body, and response together:

npm install openapi-fetch
npm install -D openapi-typescript
npx openapi-typescript \
  node_modules/@across-protocol/acxv-api-schema/openapi.json \
  -o src/acxv-api.d.ts
import createClient from "openapi-fetch";
import type { paths } from "./acxv-api";

const client = createClient<paths>({
  baseUrl: "https://acxv.example.com",
  headers: { "X-API-Key": process.env.ACXV_API_KEY ?? "" },
});

// `body` is checked against SubmitOrderRequest; `data` is SubmitOrderResponse.
const { data, error } = await client.POST("/submit", { body: order });

Auth headers differ by endpoint — /submit takes X-API-Key, while relayer endpoints take X-Relayer-Key plus the X-Auth-Message / X-Auth-Signature pair. Each operation's security block names which it requires, and components.securitySchemes maps those names to headers.

Runtime validation

Validate against schema.json, which covers the event and WebSocket frames that OpenAPI cannot express:

import Ajv2020 from "ajv/dist/2020";
import schema from "@across-protocol/acxv-api-schema";

// `Ajv2020`, not the default `ajv` export: the bundle declares draft 2020-12 and
// the default build only carries the draft-07 meta-schema.
const ajv = new Ajv2020({ schemas: [schema] });
const validateResult = ajv.getSchema(
  `${schema.$id}#/$defs/RelayerResultResponse`,
);

if (!validateResult?.(frame)) {
  throw new Error(ajv.errorsText(validateResult?.errors));
}

Types without a client

npm install -D json-schema-to-typescript
npx json2ts \
  --unreachableDefinitions \
  -i node_modules/@across-protocol/acxv-api-schema/schema.json \
  -o src/acxv-schema.d.ts
import type { SubmitOrderRequest, SubmitOrderResponse } from "./acxv-schema";

Rendered reference

npx @redocly/cli preview-docs node_modules/@across-protocol/acxv-api-schema/openapi.json

Every deployment also serves its own copy — GET /openapi.json for the document and GET /docs for the rendered page, both unauthenticated. Those bytes are the contract that deployment is actually running, which is the authoritative answer when a published artifact and a live service seem to disagree.

Reading the artifacts directly

import schema from "@across-protocol/acxv-api-schema";
import openapi from "@across-protocol/acxv-api-schema/openapi.json";

// Endpoint metadata, keyed "METHOD /path", including the admin surface.
const submit = schema["x-endpoints"]["POST /submit"];
console.log(submit.requestBody.content["application/json"].schema.$ref);

// The same endpoint as an OpenAPI operation.
console.log(openapi.paths["/submit"].post.operationId); // "submitOrder"

WebSocket endpoints carry their frame schemas under x-websocket in both artifacts, since OpenAPI has no native representation for them. The HTTP response documented for those operations is the 101 upgrade.

版本与发布记录

@across-protocol/acxv-api-schema 共发布 93 个版本,首次发布于 2026/05/08;过去 12 个月发布了 93 个版本。

版本发布日期距今
0.1.0-master.46dc04elatest2026/11/051 天前
0.1.0-staging.c9e27ecstaging2026/11/041 天前
0.1.0-staging.5b4c06a2026/11/041 天前
0.1.0-staging.52f946a2026/11/041 天前
0.1.0-master.7a5c87c2026/11/042 天前
0.1.0-staging.6ecc1f42026/11/042 天前

其他发布通道:beta-local → 0.1.0,staging → 0.1.0-staging.c9e27ec。

关于 @across-protocol/acxv-api-schema 的常见问题

@across-protocol/acxv-api-schema 是什么?

JSON Schema bundle and OpenAPI 3.1 document for the ACXV API.

如何安装 @across-protocol/acxv-api-schema?

在项目目录运行 npm install @across-protocol/acxv-api-schema,或使用 pnpm add / yarn add / bun add。

@across-protocol/acxv-api-schema 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/across-protocol__acxv-api-schema 是否存在。

@across-protocol/acxv-api-schema 可以商用吗?

@across-protocol/acxv-api-schema 使用 GPL-3.0 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@across-protocol/acxv-api-schema 的下载量有多少?

根据 npm 官方下载统计,@across-protocol/acxv-api-schema 在 2026/10/05 – 2026/11/03 这 30 天内被下载 6,813 次,日均约 227 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@across-protocol/acxv-api-schema 还在维护吗?

最新版本 0.1.0-master.46dc04e 发布于 2026/11/05(1 天前);至今共发布 93 个版本,其中过去 12 个月发布了 93 个;首次发布于 2026/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。