# teeny-request

> Like request, but smaller.

Latest version **11.0.1** (published 2026-08-11) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install teeny-request
pnpm add teeny-request
yarn add teeny-request
bun add teeny-request
```

## 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 | 11.0.1 |
| Published | 2026-08-11 |
| First published | 2018-08-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=22 |
| Dependencies | 4 |
| Unpacked size | 53.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3196 |
| Author | fhinkel |
| Maintainers | justinbeckwith, fhinkel, kinwa91, google-wombot |
| Keywords | request, node-fetch, fetch |

## Links

- npm: https://www.npmjs.com/package/teeny-request
- Repository: https://github.com/googleapis/google-cloud-node
- Homepage: https://github.com/googleapis/google-cloud-node/tree/main/core/packages/teeny-request
- Issues: https://github.com/googleapis/google-cloud-node/issues
- npm.io page: https://npm.io/package/teeny-request

## Dependencies (4)

- [node-fetch](https://npm.io/package/node-fetch.md) ^3.3.2
- [stream-events](https://npm.io/package/stream-events.md) ^1.0.5
- [http-proxy-agent](https://npm.io/package/http-proxy-agent.md) ^7.0.0
- [https-proxy-agent](https://npm.io/package/https-proxy-agent.md) ^7.0.1

## 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

- 11.0.1 (latest) — 2026-08-11
- 10.1.4 (legacy-18) — 2026-07-23
- 9.0.0 (legacy-14) — 2023-07-20
- 8.0.3 (legacy-12) — 2023-02-21
- 7.2.0 (legacy-10) — 2022-04-01
- 6.0.2 (legacy-8) — 2020-02-10
- 11.0.0 — 2026-07-30
- 10.1.3 — 2026-06-04
- 10.1.2 — 2026-03-24
- 10.1.0 — 2025-04-08
- 10.0.0 — 2025-02-18
- 8.0.2 — 2022-09-26
- 8.0.1 — 2022-08-26
- 8.0.0 — 2022-05-16
- 7.1.3 — 2021-09-27
- … 46 more at https://npm.io/package/teeny-request/versions

## README

[![Build Status](https://travis-ci.org/googleapis/teeny-request.svg?branch=master)](https://travis-ci.org/googleapis/teeny-request)

**_THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024. RELEVANT FUNCTIONALITIES HAVE BEEN MOVED TO [GOOGLEAPIS/GAXIOS](https://github.com/googleapis/gaxios)_**

# teeny-request 

Like `request`, but much smaller - and with less options. Uses `node-fetch` under the hood. 
Pop it in where you would use `request`. Improves load and parse time of modules. 

```js
const request = require('teeny-request').teenyRequest;

request({uri: 'http://ip.jsontest.com/'}, function (error, response, body) {
  console.log('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the JSON.
});
```

For TypeScript, you can use `@types/request`. 

```ts
import {teenyRequest as request} from 'teeny-request';
import * as r from 'request'; // Only for type declarations

request({uri: 'http://ip.jsontest.com/'}, (error: any, response: r.Response, body: any) => {
  console.log('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the JSON.
});
```



## teenyRequest(options, callback)

Options are limited to the following 

* uri
* method, default GET
* headers
* json
* qs
* useQuerystring
* timeout in ms
* gzip
* proxy

```ts
request({uri:'http://service.com/upload', method:'POST', json: {key:'value'}}, function(err,httpResponse,body){ /* ... */ })
```

The callback argument gets 3 arguments:

 * An error when applicable (usually from http.ClientRequest object)
 * A response object with statusCode, a statusMessage, and a body
 * The third is the response body (JSON object)

## defaults(options)

Set default options for every `teenyRequest` call.

```ts
let defaultRequest = teenyRequest.defaults({timeout: 60000});
      defaultRequest({uri: 'http://ip.jsontest.com/'}, function (error, response, body) {
            assert.ifError(error);
            assert.strictEqual(response.statusCode, 200);
            console.log(body.ip);
            assert.notEqual(body.ip, null);
            
            done();
        });
```        

## Proxy environment variables
If environment variables `HTTP_PROXY`, `HTTPS_PROXY`, or `NO_PROXY` are set, they are respected.

## Building with Webpack 4+
Since 4.0.0, Webpack uses `javascript/esm` for `.mjs` files which handles ESM more strictly compared to `javascript/auto`. If you get the error `Can't import the named export 'PassThrough' from non EcmaScript module`, please add the following to your Webpack config:

```js
{
    test: /\.mjs$/,
    type: 'javascript/auto',
},
```

## Motivation
`request` has a ton of options and features and is accordingly large. Requiring a module incurs load and parse time. For
`request`, that is around 600ms.

![Load time of request measured with require-so-slow](https://user-images.githubusercontent.com/101553/44694187-20357700-aa3a-11e8-9116-b8ae794cbc27.png)

`teeny-request` doesn't have any of the bells and whistles that `request` has, but is so much faster to load. If startup time is an issue and you don't need much beyond a basic GET and POST, you can use `teeny-request`.

## Thanks
Special thanks to [billyjacobson](https://github.com/billyjacobson) for suggesting the name. Please report all bugs to them. Just kidding. Please open issues.

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