# @turnkey/http

> Typed HTTP client for interacting with Turnkey API

Latest version **6.6.0** (published 2026-09-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @turnkey/http
pnpm add @turnkey/http
yarn add @turnkey/http
bun add @turnkey/http
```

## Health

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

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

Warnings: low downloads; large bundle.

## Facts

| | |
|---|---|
| Version | 6.6.0 |
| Published | 2026-09-22 |
| First published | 2023-01-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 4 |
| Unpacked size | 18.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 101 |
| Author | Turnkey |
| Maintainers | andrewtk, r-n-o, jack-kearney-tkhq |
| Keywords | Turnkey |

## Links

- npm: https://www.npmjs.com/package/@turnkey/http
- Repository: https://github.com/tkhq/sdk
- Issues: https://github.com/tkhq/sdk/issues
- npm.io page: https://npm.io/package/@turnkey/http

## Dependencies (4)

- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.1.5
- [@turnkey/encoding](https://npm.io/package/@turnkey/encoding.md) 0.6.0
- [@turnkey/api-key-stamper](https://npm.io/package/@turnkey/api-key-stamper.md) 0.6.17
- [@turnkey/webauthn-stamper](https://npm.io/package/@turnkey/webauthn-stamper.md) 0.6.0

## Recent versions

- 6.6.0 (latest) — 2026-09-22
- 3.11.1-beta.0 (beta) — 2025-09-05
- 6.5.1 — 2026-09-22
- 6.5.0 — 2026-09-15
- 6.4.0 — 2026-09-04
- 6.3.0 — 2026-08-27
- 6.2.1 — 2026-08-14
- 6.2.0 — 2026-08-12
- 6.1.0 — 2026-08-06
- 6.0.0 — 2026-08-06
- 5.0.0 — 2026-07-16
- 4.1.1 — 2026-06-12
- 4.1.0 — 2026-06-02
- 4.0.0 — 2026-05-05
- 3.18.1 — 2026-03-30
- … 107 more at https://npm.io/package/@turnkey/http/versions

## README

# @turnkey/http

[![npm](https://img.shields.io/npm/v/@turnkey/http?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/http)

A lower-level, fully typed HTTP client for interacting with [Turnkey](https://turnkey.com) API.

For signing transactions and messages, check out the higher-level [`@turnkey/ethers`](https://www.npmjs.com/package/@turnkey/ethers) or [`@turnkey/viem`](https://www.npmjs.com/package/@turnkey/viem) signers.

Turnkey API documentation lives here: https://docs.turnkey.com.

## Getting started

```bash
$ npm install @turnkey/http
```

```typescript
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
import { TurnkeyClient } from "@turnkey/http";

// This stamper produces signatures using the API key pair passed in.
const stamper = new ApiKeyStamper({
  apiPublicKey: "...",
  apiPrivateKey: "...",
});

// The Turnkey client uses the passed in stamper to produce signed requests
// and sends them to Turnkey
const client = new TurnkeyClient(
  {
    baseUrl: "https://api.turnkey.com",
  },
  stamper,
);

// Now you can make authenticated requests!
const data = await client.getWhoami({
  organizationId: "<Your organization id>",
});
```

## HTTP fetchers

`@turnkey/http` provides fully typed http fetchers for interacting with the Turnkey API. You can find all available methods [here](/packages/http/src/__generated__/services/coordinator/public/v1/public_api.fetcher.ts). The types of input parameters and output responses are also exported for convenience.

The OpenAPI spec that generates all fetchers is also [included](/packages/http/src/__generated__/services/coordinator/public/v1/public_api.swagger.json) in the package.

## `withAsyncPolling(...)` helper

All Turnkey mutation endpoints are asynchronous (with the exception of private key-related signing endpoints, e.g. `/submit/sign_transaction`, `/submit/sign_raw_payload`). To help you simplify async mutations, `@turnkey/http` provides a `withAsyncPolling(...)` wrapper. Here's a quick example:

```typescript
import { withAsyncPolling, TurnkeyActivityError } from "@turnkey/http";

// Use `withAsyncPolling(...)` to wrap & create a fetcher with built-in async polling support
const fetcher = withAsyncPolling({
  request: client.createPrivateKeys,
});

// The fetcher remains fully typed. After submitting the request,
// it'll poll until the activity reaches a terminal state.
try {
  const activity = await fetcher({
    body: {
      /* ... */
    },
  });

  // Success!
  console.log(
    activity.result.createPrivateKeysResultV2?.privateKeys?.[0]?.privateKeyId,
  );
} catch (error) {
  if (error instanceof TurnkeyActivityError) {
    // In case the activity is rejected, failed, or requires consensus,
    // a rich `TurnkeyActivityError` will be thrown. You can read from
    // `TurnkeyActivityError` to find out why the activity didn't succeed.
    //
    // For instance, if your activity requires consensus and doesn't have
    // enough approvals, you can get the `activityId` from `TurnkeyActivityError`,
    // store it somewhere, then re-fetch the activity via `.postGetActivity(...)`
    // when the required approvals/rejections are in place.
  }
}
```

## More examples

See [`createNewEthereumPrivateKey.ts`](/examples/chain-integrations/with-ethers/src/createNewEthereumPrivateKey.ts) in the [`with-ethers`](/examples/chain-integrations/with-ethers/) example.

## See also

- [`@turnkey/ethers`](https://www.npmjs.com/package/@turnkey/ethers): Turnkey Signer for [`Ethers`](https://docs.ethers.org/v6/api/providers/#Signer)
- [`@turnkey/viem`](https://www.npmjs.com/package/@turnkey/viem): Turnkey Custom Account for [`Viem`](https://viem.sh/docs/accounts/custom.html)

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