# typed-rest-client

> Node Rest and Http Clients for use with TypeScript

Latest version **3.1.2** (published 2026-09-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install typed-rest-client
pnpm add typed-rest-client
yarn add typed-rest-client
bun add typed-rest-client
```

## Health

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

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.1.2 |
| Published | 2026-09-10 |
| First published | 2017-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 20.0.0 |
| Dependencies | 5 |
| Unpacked size | 152.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 681 |
| Author | Microsoft Corporation |
| Maintainers | vsonline, martinmrazik, bsmid, edergachev, tkasparek_ms, tramsing, razvanmanole, microsoft1es |
| Keywords | rest, http, client, typescript, node |

## Links

- npm: https://www.npmjs.com/package/typed-rest-client
- Repository: https://github.com/Microsoft/typed-rest-client
- Homepage: https://github.com/Microsoft/typed-rest-client#readme
- Issues: https://github.com/Microsoft/typed-rest-client/issues
- npm.io page: https://npm.io/package/typed-rest-client

## Dependencies (5)

- [qs](https://npm.io/package/qs.md) ^6.16.0
- [des.js](https://npm.io/package/des.js.md) ^1.1.0
- [js-md4](https://npm.io/package/js-md4.md) ^0.3.2
- [tunnel](https://npm.io/package/tunnel.md) 0.0.6
- [underscore](https://npm.io/package/underscore.md) ^1.13.8

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.1.2 (latest) — 2026-09-10
- 1.0.3 (preview) — 2018-01-11
- 3.1.1 — 2026-09-08
- 3.1.0 — 2026-08-13
- 3.0.0 — 2026-05-22
- 2.3.1 — 2026-04-24
- 2.3.0 — 2026-03-30
- 2.2.0 — 2026-01-07
- 2.1.0 — 2024-09-19
- 2.0.2 — 2024-07-08
- 2.0.1 — 2024-06-26
- 2.0.0 — 2024-06-04
- 1.8.11 — 2023-06-28
- 1.8.10 — 2023-06-27
- 1.8.9 — 2022-05-25
- … 34 more at https://npm.io/package/typed-rest-client/versions

## README

[![Build Status](https://dev.azure.com/ms/typed-rest-client/_apis/build/status/Microsoft.typed-rest-client?branchName=master)](https://dev.azure.com/ms/typed-rest-client/_build/latest?definitionId=42&branchName=master)


# Typed REST and HTTP Client with TypeScript Typings

A lightweight REST and HTTP client optimized for use with TypeScript with generics and async await.

## Features

  - REST and HTTP client with TypeScript generics and async/await/Promises
  - Typings included so no need to acquire separately (great for intellisense and no versioning drift)
  - Basic, Bearer and NTLM Support out of the box.  Extensible handlers for others.
  - Proxy support
  - Certificate support (Self-signed server and client cert)
  - Redirects supported

Intellisense and compile support:

![intellisense](./docs/intellisense.png)

## Install

```
npm install typed-rest-client --save
```

Or to install the latest preview:
```
npm install typed-rest-client@preview --save
```

## Samples

See the [samples](./samples) for complete coding examples. Also see the [REST](./test/tests/resttests.ts) and [HTTP](./test/tests/httptests.ts) tests for detailed examples.

## Errors

### HTTP

The HTTP client does not throw unless truly exceptional.

* A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
* Redirects (3xx) will be followed by default.


See [HTTP tests](./test/tests/httptests.ts) for detailed examples.

### REST

The REST client is a high-level client which uses the HTTP client.  Its responsibility is to turn a body into a typed resource object.  

* A 200 will be success.  
* Redirects (3xx) will be followed.  
* A 404 will not throw but the result object will be null and the result statusCode will be set.
* Other 4xx and 5xx errors will throw.  The status code will be attached to the error object.  If a RESTful error object is returned (`{ message: xxx}`), then the error message will be that.  Otherwise, it will be a generic, `Failed Request: (xxx)`.

See [REST tests](./test/tests/resttests.ts) for detailed examples.

## Debugging

To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:

```
export NODE_DEBUG=http
```

or

```
set NODE_DEBUG=http
```

## Node support

v2 - [current, maintained] - Supports node 16 and above
v1 - End Of Life, for Node < 16, contains security vulnerabilities, use at your own risk  

## Contributing

To contribute to this repository, see the [contribution guide](./CONTRIBUTING.md)

To build:

```bash
$ npm run build
```

To run all tests:
```bash
$ npm test
```

To just run unit tests:
```bash
$ npm run units
```

## Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Security Issues

Do you think there might be a security issue?
Have you been phished or identified a security vulnerability?
Please don't report it here - let us know by sending an email to secure@microsoft.com.

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