# httpsnippet-client-api

> An HTTPSnippet client for generating snippets for the `api` module.

Latest version **7.0.2** (published 2026-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install httpsnippet-client-api
pnpm add httpsnippet-client-api
yarn add httpsnippet-client-api
bun add httpsnippet-client-api
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2026-08-18 |
| First published | 2020-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.10.0 |
| Dependencies | 3 |
| Unpacked size | 149.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 697 |
| Author | Jon Ursenbach |
| Maintainers | gkoberger, domharrington, mjcuva, jonursenbach, rafegoldberg, darrenyong |

## Links

- npm: https://www.npmjs.com/package/httpsnippet-client-api
- Repository: https://github.com/readmeio/api
- Homepage: https://github.com/readmeio/api#readme
- Issues: https://github.com/readmeio/api/issues
- npm.io page: https://npm.io/package/httpsnippet-client-api

## Dependencies (3)

- [oas](https://npm.io/package/oas.md) ^38.1.1
- [reserved2](https://npm.io/package/reserved2.md) ^0.1.5
- [content-type](https://npm.io/package/content-type.md) ^2.0.0

## Recent versions

- 7.0.2 (latest) — 2026-08-18
- 7.0.0-next.18 (next) — 2026-07-06
- 7.0.0-beta.17 (beta) — 2026-06-29
- 7.0.1 — 2026-07-23
- 7.0.0 — 2026-07-23
- 7.0.0-beta.16 — 2025-07-30
- 7.0.0-beta.15 — 2025-07-30
- 7.0.0-beta.14 — 2025-04-14
- 7.0.0-beta.13 — 2025-04-04
- 6.1.3 — 2025-02-24
- 7.0.0-beta.12 — 2025-02-17
- 7.0.0-beta.9 — 2024-10-17
- 6.1.2 — 2024-07-03
- 7.0.0-beta.8 — 2024-06-27
- 7.0.0-beta.7 — 2024-04-11
- … 74 more at https://npm.io/package/httpsnippet-client-api/versions

## README

# httpsnippet-client-api

An [HTTPSnippet](https://npm.im/httpsnippet) client for generating snippets for the [api](https://npm.im/api) module.

[![npm](https://img.shields.io/npm/v/httpsnippet-client-api)](https://npm.im/api) [![Build](https://github.com/readmeio/api/workflows/CI/badge.svg)](https://github.com/readmeio/api)

[![](https://raw.githubusercontent.com/readmeio/.github/main/oss-header.png)](https://readme.com)

## Installation

```sh
npm install --save httpsnippet-client-api
```

## Usage

```js
import { HTTPSnippet, addClientPlugin } from 'httpsnippet';
import apiClientPlugin from 'httpsnippet-client-api';

addClientPlugin('node', apiClientPlugin);

const har = {
  "log": {
    "entries": [
      {
        "request": {
          "cookies": [],
          "httpVersion": "HTTP/1.1",
          "method": "PUT",
          "headers": [
            {
              "name": "X-API-KEY",
              "value": "a5a220e"
            }
          ],
          "url": "https://httpbin.org/apiKey"
        }
      }
    ]
  }
}

const snippet = new HTTPSnippet(har);
const code = await snippet.convert('node', 'api', {
  api: {
    definition: {
      /* an OpenAPI definition object */
    }
    registryURI: '@example/v2.0#17273l2glm9fq4l5'
  }
});

console.log(code);
```

Results in the following:

```js
import sdk from '@api/example';

sdk.auth('a5a220e');
sdk
  .put('/apiKey')
  .then(({ data }}) => console.log(data))
  .catch(err => console.error(err));
```

We also support supplying a shorter `identifier` option that will take over the imported package and the variable that is created.

```js
const code = await snippet.convert('node', 'api', {
  api: {
    definition: {
      /* an OpenAPI definition object */
    }
    identifier: 'example',
    registryURI: '@example/v2.0#17273l2glm9fq4l5'
  }
});
```

```js
import example from 'example';

example.auth('a5a220e');
example
  .put('/apiKey')
  .then(({ data }}) => console.log(data))
  .catch(err => console.error(err));
```

---
_Source: https://npm.io/package/httpsnippet-client-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
