• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nktkas / hyperliquid / 17932585565

23 Sep 2025 12:11AM UTC coverage: 96.069% (+5.5%) from 90.582%
17932585565

push

github

nktkas
feat!: tree shaking support (~50% less size)

all API methods were moved to separate files and a new import point `/api` was added

breaking changes:
- import point `/schemas` replaced with `/api/[info,exchange,subscription]`
- standardization of typescript types to single pattern: [api name] + [Request,Response,Event,Parameters,Options,Types]
- private key directly supported only when creating a client instance

365 of 553 branches covered (66.0%)

Branch coverage included in aggregate %.

13134 of 13495 new or added lines in 148 files covered. (97.32%)

13173 of 13539 relevant lines covered (97.3%)

613.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.88
/src/api/info/allMids.ts
1
import * as v from "valibot";
328✔
2
import { type DeepImmutable, parser, UnsignedDecimal } from "../_common.ts";
328✔
3
import type { InfoRequestConfig } from "./_common.ts";
4

5
// -------------------- Schemas --------------------
6

7
/**
8
 * Request mid coin prices.
9
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
10
 */
11
export const AllMidsRequest = /* @__PURE__ */ (() => {
328✔
12
  return v.pipe(
555✔
13
    v.object({
555✔
14
      /** Type of request. */
15
      type: v.pipe(
555✔
16
        v.literal("allMids"),
555✔
17
        v.description("Type of request."),
555✔
18
      ),
19
      /** DEX name (empty string for main dex). */
20
      dex: v.pipe(
555✔
21
        v.optional(v.string()),
555✔
22
        v.description("DEX name (empty string for main dex)."),
555✔
23
      ),
24
    }),
555✔
25
    v.description("Request mid coin prices."),
555✔
26
  );
27
})();
328✔
28
export type AllMidsRequest = v.InferOutput<typeof AllMidsRequest>;
29

30
/**
31
 * Mapping of coin symbols to mid prices.
32
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
33
 */
34
export const AllMidsResponse = /* @__PURE__ */ (() => {
328✔
35
  return v.pipe(
555✔
36
    v.record(v.string(), UnsignedDecimal),
555✔
37
    v.description("Mapping of coin symbols to mid prices."),
555✔
38
  );
39
})();
328✔
40
export type AllMidsResponse = v.InferOutput<typeof AllMidsResponse>;
41

42
// -------------------- Function --------------------
43

44
/** Request parameters for the {@linkcode allMids} function. */
45
export type AllMidsParameters = Omit<v.InferInput<typeof AllMidsRequest>, "type">;
46

47
/**
48
 * Request mid coin prices.
49
 * @param config - General configuration for Info API requests.
50
 * @param params - Parameters specific to the API request.
51
 * @param signal - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) can be used to cancel the request by calling [`abort()`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) on the corresponding [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
52
 * @returns Mapping of coin symbols to mid prices.
53
 *
54
 * @throws {TransportError} When the transport layer throws an error.
55
 *
56
 * @see https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/info-endpoint#retrieve-mids-for-all-coins
57
 * @example
58
 * ```ts
59
 * import { HttpTransport } from "@nktkas/hyperliquid";
60
 * import { allMids } from "@nktkas/hyperliquid/api/info";
61
 *
62
 * const transport = new HttpTransport(); // or `WebSocketTransport`
63
 * const data = await allMids({ transport });
64
 * ```
65
 */
66
export function allMids(
67
  config: InfoRequestConfig,
68
  params?: DeepImmutable<AllMidsParameters>,
69
  signal?: AbortSignal,
70
): Promise<AllMidsResponse>;
71
export function allMids(
72
  config: InfoRequestConfig,
73
  signal?: AbortSignal,
74
): Promise<AllMidsResponse>;
75
export function allMids(
328✔
76
  config: InfoRequestConfig,
328✔
77
  paramsOrSignal?: DeepImmutable<AllMidsParameters> | AbortSignal,
328✔
78
  maybeSignal?: AbortSignal,
328✔
79
): Promise<AllMidsResponse> {
NEW
80
  const params = paramsOrSignal instanceof AbortSignal ? {} : paramsOrSignal;
×
NEW
81
  const signal = paramsOrSignal instanceof AbortSignal ? paramsOrSignal : maybeSignal;
×
82

83
  const request = parser(AllMidsRequest)({
330✔
84
    type: "allMids",
330✔
85
    ...params,
330✔
86
  });
330✔
87
  return config.transport.request("info", request, signal);
330✔
88
}
330✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc