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

@nijesmik/openapi-ky

v2.0.1

Published

Type-safe ky client driven by an OpenAPI schema.

Readme

@nijesmik/openapi-ky

Type-safe ky client driven by an OpenAPI schema.

한국어

Install

npm install @nijesmik/openapi-ky ky

ky is a peer dependency. Generate the paths type from your OpenAPI document with openapi-typescript and import it as shown below.

Usage

import createClient from '@nijesmik/openapi-ky';
import type { paths } from './schema'; // generated by openapi-typescript

const client = createClient<paths>({ baseUrl: 'https://api.example.com' });

// GET with path params
const user = await client
  .get('/users/{userId}', { params: { userId: 1 } })
  .json();

// POST with json body
const created = await client
  .post('/posts', { json: { title: 'Hello', content: 'World' } })
  .json();

params is a path-template substitution field added on top of ky (e.g. {userId}1). All other ky options (headers, searchParams, hooks, retry, timeout, …) pass through. See ky docs.

Configuring a default method

Optional. By default the client dispatches GET when called directly (client(path, opts)). To bind a different default, pass it as the second generic and as defaultOptions.method:

import createClient from '@nijesmik/openapi-ky';
import type { paths } from './schema';

const client = createClient<paths, 'post'>({
  baseUrl: 'https://api.example.com',
  method: 'post',
});

await client('/posts', { json: { title: 'Hello' } }).json();

The shortcut methods (client.get, client.post, …) always use the method named on the shortcut, regardless of the instance default.

Method resolution: options.method (per call) → defaultOptions.method (instance) → 'get' (ky's fallback).

Type helpers

import type { RequestBody, ResponseBody } from '@nijesmik/openapi-ky';
import type { paths } from './schema';

type CreatePostBody = RequestBody<paths, '/posts', 'post'>; // method is required
type User = ResponseBody<paths, '/users/{userId}'>; // method defaults to 'get'

Also exported: Client, PathsFor, PathParams, Options, OptionsWithRequiredMethod, JsonField, KyOptions, SearchParams, HttpMethod.

License

MIT