Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. <div align="center">
  2. <br>
  3. <br>
  4. <img width="360" src="media/logo.svg" alt="Got">
  5. <br>
  6. <br>
  7. <br>
  8. <p align="center">Huge thanks to <a href="https://moxy.studio"><img src="https://sindresorhus.com/assets/thanks/moxy-logo.svg" width="150"></a> for sponsoring me!
  9. </p>
  10. <br>
  11. <br>
  12. </div>
  13. > Simplified HTTP requests
  14. [![Build Status: Linux](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master) [![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got) [![Install size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)
  15. Got is a human-friendly and powerful HTTP request library.
  16. It was created because the popular [`request`](https://github.com/request/request) package is bloated: [![Install size](https://packagephobia.now.sh/badge?p=request)](https://packagephobia.now.sh/result?p=request)
  17. Got is for Node.js. For browsers, we recommend [Ky](https://github.com/sindresorhus/ky).
  18. ## Highlights
  19. - [Promise & stream API](#api)
  20. - [Request cancelation](#aborting-the-request)
  21. - [RFC compliant caching](#cache-adapters)
  22. - [Follows redirects](#followredirect)
  23. - [Retries on failure](#retry)
  24. - [Progress events](#onuploadprogress-progress)
  25. - [Handles gzip/deflate](#decompress)
  26. - [Timeout handling](#timeout)
  27. - [Errors with metadata](#errors)
  28. - [JSON mode](#json)
  29. - [WHATWG URL support](#url)
  30. - [Hooks](#hooks)
  31. - [Instances with custom defaults](#instances)
  32. - [Composable](advanced-creation.md#merging-instances)
  33. - [Electron support](#useelectronnet)
  34. - [Used by ~2000 packages and ~500K repos](https://github.com/sindresorhus/got/network/dependents)
  35. - Actively maintained
  36. [Moving from Request?](migration-guides.md)
  37. [See how Got compares to other HTTP libraries](#comparison)
  38. ## Install
  39. ```
  40. $ npm install got
  41. ```
  42. <a href="https://www.patreon.com/sindresorhus">
  43. <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
  44. </a>
  45. ## Usage
  46. ```js
  47. const got = require('got');
  48. (async () => {
  49. try {
  50. const response = await got('sindresorhus.com');
  51. console.log(response.body);
  52. //=> '<!doctype html> ...'
  53. } catch (error) {
  54. console.log(error.response.body);
  55. //=> 'Internal server error ...'
  56. }
  57. })();
  58. ```
  59. ###### Streams
  60. ```js
  61. const fs = require('fs');
  62. const got = require('got');
  63. got.stream('sindresorhus.com').pipe(fs.createWriteStream('index.html'));
  64. // For POST, PUT, and PATCH methods `got.stream` returns a `stream.Writable`
  65. fs.createReadStream('index.html').pipe(got.stream.post('sindresorhus.com'));
  66. ```
  67. ### API
  68. It's a `GET` request by default, but can be changed by using different methods or in the `options`.
  69. #### got(url, [options])
  70. Returns a Promise for a [`response` object](#response) or a [stream](#streams-1) if `options.stream` is set to true.
  71. ##### url
  72. Type: `string` `Object`
  73. The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
  74. Properties from `options` will override properties in the parsed `url`.
  75. If no protocol is specified, it will default to `https`.
  76. ##### options
  77. Type: `Object`
  78. Any of the [`https.request`](https://nodejs.org/api/https.html#https_https_request_options_callback) options.
  79. ###### baseUrl
  80. Type: `string` `Object`
  81. When specified, `url` will be prepended by `baseUrl`.<br>
  82. If you specify an absolute URL, it will skip the `baseUrl`.
  83. Very useful when used with `got.extend()` to create niche-specific Got instances.
  84. Can be a string or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
  85. Slash at the end of `baseUrl` and at the beginning of the `url` argument is optional:
  86. ```js
  87. await got('hello', {baseUrl: 'https://example.com/v1'});
  88. //=> 'https://example.com/v1/hello'
  89. await got('/hello', {baseUrl: 'https://example.com/v1/'});
  90. //=> 'https://example.com/v1/hello'
  91. await got('/hello', {baseUrl: 'https://example.com/v1'});
  92. //=> 'https://example.com/v1/hello'
  93. ```
  94. ###### headers
  95. Type: `Object`<br>
  96. Default: `{}`
  97. Request headers.
  98. Existing headers will be overwritten. Headers set to `null` will be omitted.
  99. ###### stream
  100. Type: `boolean`<br>
  101. Default: `false`
  102. Returns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, [options])`.
  103. ###### body
  104. Type: `string` `Buffer` `stream.Readable` [`form-data` instance](https://github.com/form-data/form-data)
  105. **Note:** If you provide this option, `got.stream()` will be read-only.
  106. The body that will be sent with a `POST` request.
  107. If present in `options` and `options.method` is not set, `options.method` will be set to `POST`.
  108. The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
  109. ###### cookieJar
  110. Type: [`tough.CookieJar` instance](https://github.com/salesforce/tough-cookie#cookiejar)
  111. **Note:** If you provide this option, `options.headers.cookie` will be overridden.
  112. Cookie support. You don't have to care about parsing or how to store them. [Example.](#cookies)
  113. ###### encoding
  114. Type: `string` `null`<br>
  115. Default: `'utf8'`
  116. [Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data. If `null`, the body is returned as a [`Buffer`](https://nodejs.org/api/buffer.html) (binary data).
  117. ###### form
  118. Type: `boolean`<br>
  119. Default: `false`
  120. **Note:** If you provide this option, `got.stream()` will be read-only.
  121. **Note:** `body` must be a plain object. It will be converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj).
  122. If set to `true` and `Content-Type` header is not set, it will be set to `application/x-www-form-urlencoded`.
  123. ###### json
  124. Type: `boolean`<br>
  125. Default: `false`
  126. **Note:** If you use `got.stream()`, this option will be ignored.
  127. **Note:** `body` must be a plain object or array and will be stringified.
  128. If set to `true` and `Content-Type` header is not set, it will be set to `application/json`.
  129. Parse response body with `JSON.parse` and set `accept` header to `application/json`. If used in conjunction with the `form` option, the `body` will the stringified as querystring and the response parsed as JSON.
  130. ###### query
  131. Type: `string` `Object<string, string|number>` [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
  132. Query string that will be added to the request URL. This will override the query string in `url`.
  133. If you need to pass in an array, you can do it using a `URLSearchParams` instance:
  134. ```js
  135. const got = require('got');
  136. const query = new URLSearchParams([['key', 'a'], ['key', 'b']]);
  137. got('https://example.com', {query});
  138. console.log(query.toString());
  139. //=> 'key=a&key=b'
  140. ```
  141. And if you need a different array format, you could use the [`query-string`](https://github.com/sindresorhus/query-string) package:
  142. ```js
  143. const got = require('got');
  144. const queryString = require('query-string');
  145. const query = queryString.stringify({key: ['a', 'b']}, {arrayFormat: 'bracket'});
  146. got('https://example.com', {query});
  147. console.log(query);
  148. //=> 'key[]=a&key[]=b'
  149. ```
  150. ###### timeout
  151. Type: `number` `Object`
  152. Milliseconds to wait for the server to end the response before aborting the request with [`got.TimeoutError`](#gottimeouterror) error (a.k.a. `request` property). By default, there's no timeout.
  153. This also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle:
  154. - `lookup` starts when a socket is assigned and ends when the hostname has been resolved. Does not apply when using a Unix domain socket.
  155. - `connect` starts when `lookup` completes (or when the socket is assigned if lookup does not apply to the request) and ends when the socket is connected.
  156. - `secureConnect` starts when `connect` completes and ends when the handshaking process completes (HTTPS only).
  157. - `socket` starts when the socket is connected. See [request.setTimeout](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback).
  158. - `response` starts when the request has been written to the socket and ends when the response headers are received.
  159. - `send` starts when the socket is connected and ends with the request has been written to the socket.
  160. - `request` starts when the request is initiated and ends when the response's end event fires.
  161. ###### retry
  162. Type: `number` `Object`<br>
  163. Default:
  164. - retries: `2`
  165. - methods: `GET` `PUT` `HEAD` `DELETE` `OPTIONS` `TRACE`
  166. - statusCodes: [`408`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) [`413`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413) [`429`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) [`500`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) [`502`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) [`503`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) [`504`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504)
  167. - maxRetryAfter: `undefined`
  168. - errorCodes: `ETIMEDOUT` `ECONNRESET` `EADDRINUSE` `ECONNREFUSED` `EPIPE` `ENOTFOUND` `ENETUNREACH` `EAI_AGAIN`
  169. An object representing `retries`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for the time until retry, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes.
  170. If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`.<br>
  171. If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request.
  172. Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 1).
  173. The `retries` property can be a `number` or a `function` with `retry` and `error` arguments. The function must return a delay in milliseconds (`0` return value cancels retry).
  174. By default, it retries *only* on the specified methods, status codes, and on these network errors:
  175. - `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached.
  176. - `ECONNRESET`: Connection was forcibly closed by a peer.
  177. - `EADDRINUSE`: Could not bind to any free port.
  178. - `ECONNREFUSED`: Connection was refused by the server.
  179. - `EPIPE`: The remote side of the stream being written has been closed.
  180. - `ENOTFOUND`: Couldn't resolve the hostname to an IP address.
  181. - `ENETUNREACH`: No internet connection.
  182. - `EAI_AGAIN`: DNS lookup timed out.
  183. ###### followRedirect
  184. Type: `boolean`<br>
  185. Default: `true`
  186. Defines if redirect responses should be followed automatically.
  187. Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4).
  188. ###### decompress
  189. Type: `boolean`<br>
  190. Default: `true`
  191. Decompress the response automatically. This will set the `accept-encoding` header to `gzip, deflate` unless you set it yourself.
  192. If this is disabled, a compressed response is returned as a `Buffer`. This may be useful if you want to handle decompression yourself or stream the raw compressed data.
  193. ###### cache
  194. Type: `Object`<br>
  195. Default: `false`
  196. [Cache adapter instance](#cache-adapters) for storing cached data.
  197. ###### request
  198. Type: `Function`<br>
  199. Default: `http.request` `https.request` *(depending on the protocol)*
  200. Custom request function. The main purpose of this is to [support HTTP2 using a wrapper](#experimental-http2-support).
  201. ###### useElectronNet
  202. Type: `boolean`<br>
  203. Default: `false`
  204. When used in Electron, Got will use [`electron.net`](https://electronjs.org/docs/api/net/) instead of the Node.js `http` module. According to the Electron docs, it should be fully compatible, but it's not entirely. See [#443](https://github.com/sindresorhus/got/issues/443) and [#461](https://github.com/sindresorhus/got/issues/461).
  205. ###### throwHttpErrors
  206. Type: `boolean`<br>
  207. Default: `true`
  208. Determines if a `got.HTTPError` is thrown for error responses (non-2xx status codes).
  209. If this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing. This may be useful if you are checking for resource availability and are expecting error responses.
  210. ###### agent
  211. Same as the [`agent` option](https://nodejs.org/api/http.html#http_http_request_url_options_callback) for `http.request`, but with an extra feature:
  212. If you require different agents for different protocols, you can pass a map of agents to the `agent` option. This is necessary because a request to one protocol might redirect to another. In such a scenario, Got will switch over to the right protocol agent for you.
  213. ```js
  214. const got = require('got');
  215. const HttpAgent = require('agentkeepalive');
  216. const {HttpsAgent} = HttpAgent;
  217. got('sindresorhus.com', {
  218. agent: {
  219. http: new HttpAgent(),
  220. https: new HttpsAgent()
  221. }
  222. });
  223. ```
  224. ###### hooks
  225. Type: `Object<string, Function[]>`
  226. Hooks allow modifications during the request lifecycle. Hook functions may be async and are run serially.
  227. ###### hooks.init
  228. Type: `Function[]`<br>
  229. Default: `[]`
  230. Called with plain [request options](#options), right before their normalization. This is especially useful in conjunction with [`got.extend()`](#instances) and [`got.create()`](advanced-creation.md) when the input needs custom handling.
  231. See the [Request migration guide](migration-guides.md#breaking-changes) for an example.
  232. **Note**: This hook must be synchronous!
  233. ###### hooks.beforeRequest
  234. Type: `Function[]`<br>
  235. Default: `[]`
  236. Called with [normalized](source/normalize-arguments.js) [request options](#options). Got will make no further changes to the request before it is sent. This is especially useful in conjunction with [`got.extend()`](#instances) and [`got.create()`](advanced-creation.md) when you want to create an API client that, for example, uses HMAC-signing.
  237. See the [AWS section](#aws) for an example.
  238. **Note:** If you modify the `body` you will need to modify the `content-length` header too, because it has already been computed and assigned.
  239. ###### hooks.beforeRedirect
  240. Type: `Function[]`<br>
  241. Default: `[]`
  242. Called with [normalized](source/normalize-arguments.js) [request options](#options). Got will make no further changes to the request. This is especially useful when you want to avoid dead sites. Example:
  243. ```js
  244. const got = require('got');
  245. got('example.com', {
  246. hooks: {
  247. beforeRedirect: [
  248. options => {
  249. if (options.hostname === 'deadSite') {
  250. options.hostname = 'fallbackSite';
  251. }
  252. }
  253. ]
  254. }
  255. });
  256. ```
  257. ###### hooks.beforeRetry
  258. Type: `Function[]`<br>
  259. Default: `[]`
  260. Called with [normalized](source/normalize-arguments.js) [request options](#options), the error and the retry count. Got will make no further changes to the request. This is especially useful when some extra work is required before the next try. Example:
  261. ```js
  262. const got = require('got');
  263. got('example.com', {
  264. hooks: {
  265. beforeRetry: [
  266. (options, error, retryCount) => {
  267. if (error.statusCode === 413) { // Payload too large
  268. options.body = getNewBody();
  269. }
  270. }
  271. ]
  272. }
  273. });
  274. ```
  275. ###### hooks.afterResponse
  276. Type: `Function[]`<br>
  277. Default: `[]`
  278. Called with [response object](#response) and a retry function.
  279. Each function should return the response. This is especially useful when you want to refresh an access token. Example:
  280. ```js
  281. const got = require('got');
  282. const instance = got.extend({
  283. hooks: {
  284. afterResponse: [
  285. (response, retryWithMergedOptions) => {
  286. if (response.statusCode === 401) { // Unauthorized
  287. const updatedOptions = {
  288. headers: {
  289. token: getNewToken() // Refresh the access token
  290. }
  291. };
  292. // Save for further requests
  293. instance.defaults.options = got.mergeOptions(instance.defaults.options, updatedOptions);
  294. // Make a new retry
  295. return retryWithMergedOptions(updatedOptions);
  296. }
  297. // No changes otherwise
  298. return response;
  299. }
  300. ]
  301. },
  302. mutableDefaults: true
  303. });
  304. ```
  305. ###### hooks.beforeError
  306. Type: `Function[]`<br>
  307. Default: `[]`
  308. Called with an `Error` instance. The error is passed to the hook right before it's thrown. This is especially useful when you want to have more detailed errors.
  309. **Note**: Errors thrown while normalizing input options are thrown directly and not part of this hook.
  310. ```js
  311. const got = require('got');
  312. got('api.github.com/some-endpoint', {
  313. hooks: {
  314. onError: [
  315. error => {
  316. const {response} = error;
  317. if (response && response.body) {
  318. error.name = 'GitHubError';
  319. error.message = `${response.body.message} (${error.statusCode})`;
  320. }
  321. return error;
  322. }
  323. ]
  324. }
  325. });
  326. ```
  327. #### Response
  328. The response object will typically be a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage), however, if returned from the cache it will be a [response-like object](https://github.com/lukechilds/responselike) which behaves in the same way.
  329. ##### request
  330. Type: `Object`
  331. **Note:** This is not a [http.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).
  332. - `gotOptions` - The options that were set on this request.
  333. ##### body
  334. Type: `string` `Object` *(depending on `options.json`)*
  335. The result of the request.
  336. ##### url
  337. Type: `string`
  338. The request URL or the final URL after redirects.
  339. ##### requestUrl
  340. Type: `string`
  341. The original request URL.
  342. ##### timings
  343. Type: `Object`
  344. The object contains the following properties:
  345. - `start` - Time when the request started.
  346. - `socket` - Time when a socket was assigned to the request.
  347. - `lookup` - Time when the DNS lookup finished.
  348. - `connect` - Time when the socket successfully connected.
  349. - `upload` - Time when the request finished uploading.
  350. - `response` - Time when the request fired the `response` event.
  351. - `end` - Time when the response fired the `end` event.
  352. - `error` - Time when the request fired the `error` event.
  353. - `phases`
  354. - `wait` - `timings.socket - timings.start`
  355. - `dns` - `timings.lookup - timings.socket`
  356. - `tcp` - `timings.connect - timings.lookup`
  357. - `request` - `timings.upload - timings.connect`
  358. - `firstByte` - `timings.response - timings.upload`
  359. - `download` - `timings.end - timings.response`
  360. - `total` - `timings.end - timings.start` or `timings.error - timings.start`
  361. **Note:** The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
  362. ##### fromCache
  363. Type: `boolean`
  364. Whether the response was retrieved from the cache.
  365. ##### redirectUrls
  366. Type: `Array`
  367. The redirect URLs.
  368. ##### retryCount
  369. Type: `number`
  370. The number of times the request was retried.
  371. #### Streams
  372. **Note:** Progress events, redirect events and request/response events can also be used with promises.
  373. #### got.stream(url, [options])
  374. Sets `options.stream` to `true`.
  375. Returns a [duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with additional events:
  376. ##### .on('request', request)
  377. `request` event to get the request object of the request.
  378. **Tip:** You can use `request` event to abort request:
  379. ```js
  380. got.stream('github.com')
  381. .on('request', request => setTimeout(() => request.abort(), 50));
  382. ```
  383. ##### .on('response', response)
  384. The `response` event to get the response object of the final request.
  385. ##### .on('redirect', response, nextOptions)
  386. The `redirect` event to get the response object of a redirect. The second argument is options for the next request to the redirect location.
  387. ##### .on('uploadProgress', progress)
  388. ##### .on('downloadProgress', progress)
  389. Progress events for uploading (sending a request) and downloading (receiving a response). The `progress` argument is an object like:
  390. ```js
  391. {
  392. percent: 0.1,
  393. transferred: 1024,
  394. total: 10240
  395. }
  396. ```
  397. If it's not possible to retrieve the body size (can happen when streaming), `total` will be `null`.
  398. ```js
  399. (async () => {
  400. const response = await got('sindresorhus.com')
  401. .on('downloadProgress', progress => {
  402. // Report download progress
  403. })
  404. .on('uploadProgress', progress => {
  405. // Report upload progress
  406. });
  407. console.log(response);
  408. })();
  409. ```
  410. ##### .on('error', error, body, response)
  411. The `error` event emitted in case of a protocol error (like `ENOTFOUND` etc.) or status error (4xx or 5xx). The second argument is the body of the server response in case of status error. The third argument is a response object.
  412. #### got.get(url, [options])
  413. #### got.post(url, [options])
  414. #### got.put(url, [options])
  415. #### got.patch(url, [options])
  416. #### got.head(url, [options])
  417. #### got.delete(url, [options])
  418. Sets `options.method` to the method name and makes a request.
  419. ### Instances
  420. #### got.extend([options])
  421. Configure a new `got` instance with default `options`. The `options` are merged with the parent instance's `defaults.options` using [`got.mergeOptions`](#gotmergeoptionsparentoptions-newoptions). You can access the resolved options with the `.defaults` property on the instance.
  422. ```js
  423. const client = got.extend({
  424. baseUrl: 'https://example.com',
  425. headers: {
  426. 'x-unicorn': 'rainbow'
  427. }
  428. });
  429. client.get('/demo');
  430. /* HTTP Request =>
  431. * GET /demo HTTP/1.1
  432. * Host: example.com
  433. * x-unicorn: rainbow
  434. */
  435. ```
  436. ```js
  437. (async () => {
  438. const client = got.extend({
  439. baseUrl: 'httpbin.org',
  440. headers: {
  441. 'x-foo': 'bar'
  442. }
  443. });
  444. const {headers} = (await client.get('/headers', {json: true})).body;
  445. //=> headers['x-foo'] === 'bar'
  446. const jsonClient = client.extend({
  447. json: true,
  448. headers: {
  449. 'x-baz': 'qux'
  450. }
  451. });
  452. const {headers: headers2} = (await jsonClient.get('/headers')).body;
  453. //=> headers2['x-foo'] === 'bar'
  454. //=> headers2['x-baz'] === 'qux'
  455. })();
  456. ```
  457. **Tip:** Need more control over the behavior of Got? Check out the [`got.create()`](advanced-creation.md).
  458. #### got.mergeOptions(parentOptions, newOptions)
  459. Extends parent options. Avoid using [object spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals) as it doesn't work recursively:
  460. ```js
  461. const a = {headers: {cat: 'meow', wolf: ['bark', 'wrrr']}};
  462. const b = {headers: {cow: 'moo', wolf: ['auuu']}};
  463. {...a, ...b} // => {headers: {cow: 'moo', wolf: ['auuu']}}
  464. got.mergeOptions(a, b) // => {headers: {cat: 'meow', cow: 'moo', wolf: ['auuu']}}
  465. ```
  466. Options are deeply merged to a new object. The value of each key is determined as follows:
  467. - If the new property is set to `undefined`, it keeps the old one.
  468. - If the parent property is an instance of `URL` and the new value is a `string` or `URL`, a new URL instance is created: [`new URL(new, parent)`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#Syntax).
  469. - If the new property is a plain `Object`:
  470. - If the parent property is a plain `Object` too, both values are merged recursively into a new `Object`.
  471. - Otherwise, only the new value is deeply cloned.
  472. - If the new property is an `Array`, it overwrites the old one with a deep clone of the new property.
  473. - Otherwise, the new value is assigned to the key.
  474. #### got.defaults
  475. Type: `Object`
  476. The default Got options.
  477. ## Errors
  478. Each error contains `host`, `hostname`, `method`, `path`, `protocol`, `url` and `gotOptions` properties to make debugging easier.
  479. In Promise mode, the `response` is attached to the error.
  480. #### got.CacheError
  481. When a cache method fails, for example, if the database goes down or there's a filesystem error.
  482. #### got.RequestError
  483. When a request fails. Contains a `code` property with error class code, like `ECONNREFUSED`.
  484. #### got.ReadError
  485. When reading from response stream fails.
  486. #### got.ParseError
  487. When `json` option is enabled, server response code is 2xx, and `JSON.parse` fails. Includes `statusCode` and `statusMessage` properties.
  488. #### got.HTTPError
  489. When the server response code is not 2xx. Includes `body`, `statusCode`, `statusMessage`, and `redirectUrls` properties.
  490. #### got.MaxRedirectsError
  491. When the server redirects you more than ten times. Includes a `statusCode`, `statusMessage`, and `redirectUrls` property which is an array of the URLs Got was redirected to before giving up.
  492. #### got.UnsupportedProtocolError
  493. When given an unsupported protocol.
  494. #### got.CancelError
  495. When the request is aborted with `.cancel()`.
  496. #### got.TimeoutError
  497. When the request is aborted due to a [timeout](#timeout). Includes an `event` property.
  498. ## Aborting the request
  499. The promise returned by Got has a [`.cancel()`](https://github.com/sindresorhus/p-cancelable) method which when called, aborts the request.
  500. ```js
  501. (async () => {
  502. const request = got(url, options);
  503. // …
  504. // In another part of the code
  505. if (something) {
  506. request.cancel();
  507. }
  508. // …
  509. try {
  510. await request;
  511. } catch (error) {
  512. if (request.isCanceled) { // Or `error instanceof got.CancelError`
  513. // Handle cancelation
  514. }
  515. // Handle other errors
  516. }
  517. })();
  518. ```
  519. <a name="cache-adapters"></a>
  520. ## Cache
  521. Got implements [RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching which works out of the box in-memory and is easily pluggable with a wide range of storage adapters. Fresh cache entries are served directly from the cache, and stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. You can read more about the underlying cache behavior in the [`cacheable-request` documentation](https://github.com/lukechilds/cacheable-request).
  522. You can use the JavaScript `Map` type as an in-memory cache:
  523. ```js
  524. const got = require('got');
  525. const map = new Map();
  526. (async () => {
  527. let response = await got('sindresorhus.com', {cache: map});
  528. console.log(response.fromCache);
  529. //=> false
  530. response = await got('sindresorhus.com', {cache: map});
  531. console.log(response.fromCache);
  532. //=> true
  533. })();
  534. ```
  535. Got uses [Keyv](https://github.com/lukechilds/keyv) internally to support a wide range of storage adapters. For something more scalable you could use an [official Keyv storage adapter](https://github.com/lukechilds/keyv#official-storage-adapters):
  536. ```
  537. $ npm install @keyv/redis
  538. ```
  539. ```js
  540. const got = require('got');
  541. const KeyvRedis = require('@keyv/redis');
  542. const redis = new KeyvRedis('redis://user:pass@localhost:6379');
  543. got('sindresorhus.com', {cache: redis});
  544. ```
  545. Got supports anything that follows the Map API, so it's easy to write your own storage adapter or use a third-party solution.
  546. For example, the following are all valid storage adapters:
  547. ```js
  548. const storageAdapter = new Map();
  549. // Or
  550. const storageAdapter = require('./my-storage-adapter');
  551. // Or
  552. const QuickLRU = require('quick-lru');
  553. const storageAdapter = new QuickLRU({maxSize: 1000});
  554. got('sindresorhus.com', {cache: storageAdapter});
  555. ```
  556. View the [Keyv docs](https://github.com/lukechilds/keyv) for more information on how to use storage adapters.
  557. ## Proxies
  558. You can use the [`tunnel`](https://github.com/koichik/node-tunnel) package with the `agent` option to work with proxies:
  559. ```js
  560. const got = require('got');
  561. const tunnel = require('tunnel');
  562. got('sindresorhus.com', {
  563. agent: tunnel.httpOverHttp({
  564. proxy: {
  565. host: 'localhost'
  566. }
  567. })
  568. });
  569. ```
  570. Check out [`global-tunnel`](https://github.com/np-maintain/global-tunnel) if you want to configure proxy support for all HTTP/HTTPS traffic in your app.
  571. ## Cookies
  572. You can use the [`tough-cookie`](https://github.com/salesforce/tough-cookie) package:
  573. ```js
  574. const got = require('got');
  575. const {CookieJar} = require('tough-cookie');
  576. const cookieJar = new CookieJar();
  577. cookieJar.setCookie('foo=bar', 'https://www.google.com');
  578. got('google.com', {cookieJar});
  579. ```
  580. ## Form data
  581. You can use the [`form-data`](https://github.com/form-data/form-data) package to create POST request with form data:
  582. ```js
  583. const fs = require('fs');
  584. const got = require('got');
  585. const FormData = require('form-data');
  586. const form = new FormData();
  587. form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
  588. got.post('google.com', {
  589. body: form
  590. });
  591. ```
  592. ## OAuth
  593. You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) package to create a signed OAuth request:
  594. ```js
  595. const got = require('got');
  596. const crypto = require('crypto');
  597. const OAuth = require('oauth-1.0a');
  598. const oauth = OAuth({
  599. consumer: {
  600. key: process.env.CONSUMER_KEY,
  601. secret: process.env.CONSUMER_SECRET
  602. },
  603. signature_method: 'HMAC-SHA1',
  604. hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')
  605. });
  606. const token = {
  607. key: process.env.ACCESS_TOKEN,
  608. secret: process.env.ACCESS_TOKEN_SECRET
  609. };
  610. const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
  611. got(url, {
  612. headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),
  613. json: true
  614. });
  615. ```
  616. ## Unix Domain Sockets
  617. Requests can also be sent via [unix domain sockets](http://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket). Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH`.
  618. - `PROTOCOL` - `http` or `https` *(optional)*
  619. - `SOCKET` - Absolute path to a unix domain socket, for example: `/var/run/docker.sock`
  620. - `PATH` - Request path, for example: `/v2/keys`
  621. ```js
  622. got('http://unix:/var/run/docker.sock:/containers/json');
  623. // Or without protocol (HTTP by default)
  624. got('unix:/var/run/docker.sock:/containers/json');
  625. ```
  626. ## AWS
  627. Requests to AWS services need to have their headers signed. This can be accomplished by using the [`aws4`](https://www.npmjs.com/package/aws4) package. This is an example for querying an ["API Gateway"](https://docs.aws.amazon.com/apigateway/api-reference/signing-requests/) with a signed request.
  628. ```js
  629. const AWS = require('aws-sdk');
  630. const aws4 = require('aws4');
  631. const got = require('got');
  632. const chain = new AWS.CredentialProviderChain();
  633. // Create a Got instance to use relative paths and signed requests
  634. const awsClient = got.extend({
  635. baseUrl: 'https://<api-id>.execute-api.<api-region>.amazonaws.com/<stage>/',
  636. hooks: {
  637. beforeRequest: [
  638. async options => {
  639. const credentials = await chain.resolvePromise();
  640. aws4.sign(options, credentials);
  641. }
  642. ]
  643. }
  644. });
  645. const response = await awsClient('endpoint/path', {
  646. // Request-specific options
  647. });
  648. ```
  649. ## Testing
  650. You can test your requests by using the [`nock`](https://github.com/node-nock/nock) package to mock an endpoint:
  651. ```js
  652. const got = require('got');
  653. const nock = require('nock');
  654. nock('https://sindresorhus.com')
  655. .get('/')
  656. .reply(200, 'Hello world!');
  657. (async () => {
  658. const response = await got('sindresorhus.com');
  659. console.log(response.body);
  660. //=> 'Hello world!'
  661. })();
  662. ```
  663. If you need real integration tests you can use [`create-test-server`](https://github.com/lukechilds/create-test-server):
  664. ```js
  665. const got = require('got');
  666. const createTestServer = require('create-test-server');
  667. (async () => {
  668. const server = await createTestServer();
  669. server.get('/', 'Hello world!');
  670. const response = await got(server.url);
  671. console.log(response.body);
  672. //=> 'Hello world!'
  673. await server.close();
  674. })();
  675. ```
  676. ## Tips
  677. ### User Agent
  678. It's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default, it's the URL to this repo. You can omit this header by setting it to `null`.
  679. ```js
  680. const got = require('got');
  681. const pkg = require('./package.json');
  682. got('sindresorhus.com', {
  683. headers: {
  684. 'user-agent': `my-package/${pkg.version} (https://github.com/username/my-package)`
  685. }
  686. });
  687. got('sindresorhus.com', {
  688. headers: {
  689. 'user-agent': null
  690. }
  691. });
  692. ```
  693. ### 304 Responses
  694. Bear in mind; if you send an `if-modified-since` header and receive a `304 Not Modified` response, the body will be empty. It's your responsibility to cache and retrieve the body contents.
  695. ### Custom endpoints
  696. Use `got.extend()` to make it nicer to work with REST APIs. Especially if you use the `baseUrl` option.
  697. **Note:** Not to be confused with [`got.create()`](advanced-creation.md), which has no defaults.
  698. ```js
  699. const got = require('got');
  700. const pkg = require('./package.json');
  701. const custom = got.extend({
  702. baseUrl: 'example.com',
  703. json: true,
  704. headers: {
  705. 'user-agent': `my-package/${pkg.version} (https://github.com/username/my-package)`
  706. }
  707. });
  708. // Use `custom` exactly how you use `got`
  709. (async () => {
  710. const list = await custom('/v1/users/list');
  711. })();
  712. ```
  713. **Tip:** Need to merge some instances into a single one? Check out [`got.mergeInstances()`](advanced-creation.md#merging-instances).
  714. ### Experimental HTTP2 support
  715. Got provides an experimental support for HTTP2 using the [`http2-wrapper`](https://github.com/szmarczak/http2-wrapper) package:
  716. ```js
  717. const got = require('got');
  718. const {request} = require('http2-wrapper');
  719. const h2got = got.extend({request});
  720. (async () => {
  721. const {body} = await h2got('https://nghttp2.org/httpbin/headers');
  722. console.log(body);
  723. })();
  724. ```
  725. ## Comparison
  726. | | `got` | [`request`][r0] | [`node-fetch`][n0] | [`axios`][a0] | [`superagent`][s0] |
  727. |-----------------------|:--------------:|:---------------:|:------------------:|:---------------:|:--------------------:|
  728. | HTTP/2 support | ❔ | ✖ | ✖ | ✖ | ✔\*\* |
  729. | Browser support | ✖ | ✖ | ✔\* | ✔ | ✔ |
  730. | Electron support | ✔ | ✖ | ✖ | ✖ | ✖ |
  731. | Promise API | ✔ | ✔ | ✔ | ✔ | ✔ |
  732. | Stream API | ✔ | ✔ | Node.js only | ✖ | ✔ |
  733. | Request cancelation | ✔ | ✖ | ✔ | ✔ | ✔ |
  734. | RFC compliant caching | ✔ | ✖ | ✖ | ✖ | ✖ |
  735. | Cookies (out-of-box) | ✔ | ✔ | ✖ | ✖ | ✖ |
  736. | Follows redirects | ✔ | ✔ | ✔ | ✔ | ✔ |
  737. | Retries on failure | ✔ | ✖ | ✖ | ✖ | ✔ |
  738. | Progress events | ✔ | ✖ | ✖ | Browser only | ✔ |
  739. | Handles gzip/deflate | ✔ | ✔ | ✔ | ✔ | ✔ |
  740. | Advanced timeouts | ✔ | ✖ | ✖ | ✖ | ✖ |
  741. | Timings | ✔ | ✔ | ✖ | ✖ | ✖ |
  742. | Errors with metadata | ✔ | ✖ | ✖ | ✔ | ✖ |
  743. | JSON mode | ✔ | ✔ | ✖ | ✔ | ✔ |
  744. | Custom defaults | ✔ | ✔ | ✖ | ✔ | ✖ |
  745. | Composable | ✔ | ✖ | ✖ | ✖ | ✔ |
  746. | Hooks | ✔ | ✖ | ✖ | ✔ | ✖ |
  747. | Issues open | [![][gio]][g1] | [![][rio]][r1] | [![][nio]][n1] | [![][aio]][a1] | [![][sio]][s1] |
  748. | Issues closed | [![][gic]][g2] | [![][ric]][r2] | [![][nic]][n2] | [![][aic]][a2] | [![][sic]][s2] |
  749. | Downloads | [![][gd]][g3] | [![][rd]][r3] | [![][nd]][n3] | [![][ad]][a3] | [![][sd]][s3] |
  750. | Coverage | [![][gc]][g4] | [![][rc]][r4] | [![][nc]][n4] | [![][ac]][a4] | unknown |
  751. | Build | [![][gb]][g5] | [![][rb]][r5] | [![][nb]][n5] | [![][ab]][a5] | [![][sb]][s5] |
  752. | Bugs | [![][gbg]][g6] | [![][rbg]][r6] | [![][nbg]][n6] | [![][abg]][a6] | [![][sbg]][s6] |
  753. | Dependents | [![][gdp]][g7] | [![][rdp]][r7] | [![][ndp]][n7] | [![][adp]][a7] | [![][sdp]][s7] |
  754. | Install size | [![][gis]][g8] | [![][ris]][r8] | [![][nis]][n8] | [![][ais]][a8] | [![][sis]][s8] |
  755. \* It's almost API compatible with the browser `fetch` API.<br>
  756. \*\* Need to switch the protocol manually.<br>
  757. ❔ Experimental support.
  758. <!-- GITHUB -->
  759. [r0]: https://github.com/request/request
  760. [n0]: https://github.com/bitinn/node-fetch
  761. [a0]: https://github.com/axios/axios
  762. [s0]: https://github.com/visionmedia/superagent
  763. <!-- ISSUES OPEN -->
  764. [gio]: https://badgen.net/github/open-issues/sindresorhus/got?label
  765. [rio]: https://badgen.net/github/open-issues/request/request?label
  766. [nio]: https://badgen.net/github/open-issues/bitinn/node-fetch?label
  767. [aio]: https://badgen.net/github/open-issues/axios/axios?label
  768. [sio]: https://badgen.net/github/open-issues/visionmedia/superagent?label
  769. [g1]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
  770. [r1]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
  771. [n1]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
  772. [a1]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
  773. [s1]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
  774. <!-- ISSUES CLOSED -->
  775. [gic]: https://badgen.net/github/closed-issues/sindresorhus/got?label
  776. [ric]: https://badgen.net/github/closed-issues/request/request?label
  777. [nic]: https://badgen.net/github/closed-issues/bitinn/node-fetch?label
  778. [aic]: https://badgen.net/github/closed-issues/axios/axios?label
  779. [sic]: https://badgen.net/github/closed-issues/visionmedia/superagent?label
  780. [g2]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
  781. [r2]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
  782. [n2]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
  783. [a2]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
  784. [s2]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aclosed+sort%3Aupdated-desc
  785. <!-- DOWNLOADS -->
  786. [gd]: https://badgen.net/npm/dm/got?label
  787. [rd]: https://badgen.net/npm/dm/request?label
  788. [nd]: https://badgen.net/npm/dm/node-fetch?label
  789. [ad]: https://badgen.net/npm/dm/axios?label
  790. [sd]: https://badgen.net/npm/dm/superagent?label
  791. [g3]: https://www.npmjs.com/package/got
  792. [r3]: https://www.npmjs.com/package/request
  793. [n3]: https://www.npmjs.com/package/node-fetch
  794. [a3]: https://www.npmjs.com/package/axios
  795. [s3]: https://www.npmjs.com/package/superagent
  796. <!-- COVERAGE -->
  797. [gc]: https://badgen.net/coveralls/c/github/sindresorhus/got?label
  798. [rc]: https://badgen.net/coveralls/c/github/request/request?label
  799. [nc]: https://badgen.net/coveralls/c/github/bitinn/node-fetch?label
  800. [ac]: https://badgen.net/coveralls/c/github/mzabriskie/axios?label
  801. [g4]: https://coveralls.io/github/sindresorhus/got
  802. [r4]: https://coveralls.io/github/request/request
  803. [n4]: https://coveralls.io/github/bitinn/node-fetch
  804. [a4]: https://coveralls.io/github/mzabriskie/axios
  805. <!-- BUILD -->
  806. [gb]: https://badgen.net/travis/sindresorhus/got?label
  807. [rb]: https://badgen.net/travis/request/request?label
  808. [nb]: https://badgen.net/travis/bitinn/node-fetch?label
  809. [ab]: https://badgen.net/travis/axios/axios?label
  810. [sb]: https://badgen.net/travis/visionmedia/superagent?label
  811. [g5]: https://travis-ci.org/sindresorhus/got
  812. [r5]: https://travis-ci.org/request/request
  813. [n5]: https://travis-ci.org/bitinn/node-fetch
  814. [a5]: https://travis-ci.org/axios/axios
  815. [s5]: https://travis-ci.org/visionmedia/superagent
  816. <!-- BUGS -->
  817. [gbg]: https://badgen.net/github/label-issues/sindresorhus/got/bug/open?label
  818. [rbg]: https://badgen.net/github/label-issues/request/request/Needs%20investigation/open?label
  819. [nbg]: https://badgen.net/github/label-issues/bitinn/node-fetch/bug/open?label
  820. [abg]: https://badgen.net/github/label-issues/axios/axios/bug/open?label
  821. [sbg]: https://badgen.net/github/label-issues/visionmedia/superagent/Bug/open?label
  822. [g6]: https://github.com/sindresorhus/got/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
  823. [r6]: https://github.com/request/request/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A"Needs+investigation"
  824. [n6]: https://github.com/bitinn/node-fetch/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
  825. [a6]: https://github.com/axios/axios/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abug
  826. [s6]: https://github.com/visionmedia/superagent/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3ABug
  827. <!-- DEPENDENTS -->
  828. [gdp]: https://badgen.net/npm/dependents/got?label
  829. [rdp]: https://badgen.net/npm/dependents/request?label
  830. [ndp]: https://badgen.net/npm/dependents/node-fetch?label
  831. [adp]: https://badgen.net/npm/dependents/axios?label
  832. [sdp]: https://badgen.net/npm/dependents/superagent?label
  833. [g7]: https://www.npmjs.com/package/got?activeTab=dependents
  834. [r7]: https://www.npmjs.com/package/request?activeTab=dependents
  835. [n7]: https://www.npmjs.com/package/node-fetch?activeTab=dependents
  836. [a7]: https://www.npmjs.com/package/axios?activeTab=dependents
  837. [s7]: https://www.npmjs.com/package/visionmedia?activeTab=dependents
  838. <!-- INSTALL SIZE -->
  839. [gis]: https://badgen.net/packagephobia/install/got?label
  840. [ris]: https://badgen.net/packagephobia/install/request?label
  841. [nis]: https://badgen.net/packagephobia/install/node-fetch?label
  842. [ais]: https://badgen.net/packagephobia/install/axios?label
  843. [sis]: https://badgen.net/packagephobia/install/superagent?label
  844. [g8]: https://packagephobia.now.sh/result?p=got
  845. [r8]: https://packagephobia.now.sh/result?p=request
  846. [n8]: https://packagephobia.now.sh/result?p=node-fetch
  847. [a8]: https://packagephobia.now.sh/result?p=axios
  848. [s8]: https://packagephobia.now.sh/result?p=superagent
  849. ## Related
  850. - [gh-got](https://github.com/sindresorhus/gh-got) - Got convenience wrapper to interact with the GitHub API
  851. - [gl-got](https://github.com/singapore/gl-got) - Got convenience wrapper to interact with the GitLab API
  852. - [travis-got](https://github.com/samverschueren/travis-got) - Got convenience wrapper to interact with the Travis API
  853. - [graphql-got](https://github.com/kevva/graphql-got) - Got convenience wrapper to interact with GraphQL
  854. - [GotQL](https://github.com/khaosdoctor/gotql) - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of strings
  855. ## Maintainers
  856. [![Sindre Sorhus](https://github.com/sindresorhus.png?size=100)](https://sindresorhus.com) | [![Vsevolod Strukchinsky](https://github.com/floatdrop.png?size=100)](https://github.com/floatdrop) | [![Alexander Tesfamichael](https://github.com/AlexTes.png?size=100)](https://github.com/AlexTes) | [![Luke Childs](https://github.com/lukechilds.png?size=100)](https://github.com/lukechilds) | [![Szymon Marczak](https://github.com/szmarczak.png?size=100)](https://github.com/szmarczak) | [![Brandon Smith](https://github.com/brandon93s.png?size=100)](https://github.com/brandon93s)
  857. ---|---|---|---|---|---
  858. [Sindre Sorhus](https://sindresorhus.com) | [Vsevolod Strukchinsky](https://github.com/floatdrop) | [Alexander Tesfamichael](https://alextes.me) | [Luke Childs](https://github.com/lukechilds) | [Szymon Marczak](https://github.com/szmarczak) | [Brandon Smith](https://github.com/brandon93s)
  859. ## License
  860. MIT