{"name":"simple-get","description":"Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.","version":"4.0.1","author":{"name":"Feross Aboukhadijeh","email":"feross@feross.org","url":"https://feross.org"},"browser":{"decompress-response":false},"bugs":{"url":"https://github.com/feross/simple-get/issues"},"dependencies":{"decompress-response":"^6.0.0","once":"^1.3.1","simple-concat":"^1.0.0"},"devDependencies":{"self-signed-https":"^1.0.5","standard":"*","string-to-stream":"^3.0.0","tape":"^5.0.0"},"homepage":"https://github.com/feross/simple-get","keywords":["request","http","GET","get request","http.get","redirects","follow redirects","gzip","deflate","https","http-https","stream","simple request","simple get"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git://github.com/feross/simple-get.git"},"scripts":{"test":"standard && tape test/*.js"},"funding":[{"type":"github","url":"https://github.com/sponsors/feross"},{"type":"patreon","url":"https://www.patreon.com/feross"},{"type":"consulting","url":"https://feross.org/support"}],"gitHead":"2cf41cd0a950c8694b17526fed6b975867f356dc","_id":"simple-get@4.0.1","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==","shasum":"4a39db549287c979d352112fa03fd99fd6bc3543","tarball":"http://registry-npm.ywwl.com/simple-get/download/simple-get-4.0.1.tgz","fileCount":6,"unpackedSize":14971,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh721JCRA9TVsSAnZWagAAX5kP/Atwwt+Kf4ExHP74iZ1I\nqZE6nyW4tJI8K/HPI2adLZMQrvEEkyC2gNMArUe09dZiBZedNOabTEvvjaez\nM62tCtuy7HgHrDt0y3mNZP9pkH7xVCFYYshXLNoO79pvb2G203MGIIBk2seM\nFJ6/95YpGxIfmvmmqHaKyu8HGZoKTBmdrlhvR+BFdP03PQNt7yYaL6WvxivO\nn/KDAgrZT6PyLVzV/HraPg9Ms+DR5jMWXGaRbIXaoMIa/mVlLw4Dr3t3OXnR\ni44oDEVmk2TeXtDl7NUMqZD3a+6HpZiIa8geLiB+F5RHtovTdzoh0WahRwyl\nTGZpuyZXn4yivEI0IbN7hntEl1IKdNJTCKwJTX3VWltqhwKanIZ5EIh0u8vP\nMfGlHSYw4eJNpmS0dJidD9J4hH7I82oHMXYrA/M21Yauc1tMQ/SyTzrZ8sjt\niNrQzFinKPWjxUEoYQIjNV4XiISDDyFjp6NlGOcfPYoLh4wBfYGaKnUOzLn2\nqlwEKCnefhDSYJBkFrPGc+a9dQUs4lxsix8p61aGgw11HMxfA+n7xMWqGeHf\nyIg7jMTbbY3DTgxEfimEetpmxmvE5EeINL26dU0aMWT4RJs5K9Y9jzHqUgUh\nDC6QgPh94boL82kyGihvfNFw8N6PgIJ54VEPpgCG/DSI5qSU+2c2bpg7REfC\ngjSC\r\n=VU8P\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDT0u4mmtmcfJEN9Edvh1rhScc/nCkQsw8TSzKQeA61MwIgN9zCzNtnGtTuf0q8/RPQC3NG8MYi0kJqRxNIcJyV8iE="}],"size":5530,"noattachment":false,"key":"/simple-get/-/simple-get-4.0.1.tgz"},"_npmUser":{"name":"feross","email":"feross@feross.org"},"directories":{},"maintainers":[{"name":"feross","email":"feross@feross.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-get_4.0.1_1643081033040_0.12202417012523203"},"_hasShrinkwrap":false,"readme":"# simple-get [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[travis-image]: https://img.shields.io/travis/feross/simple-get/master.svg\n[travis-url]: https://travis-ci.org/feross/simple-get\n[npm-image]: https://img.shields.io/npm/v/simple-get.svg\n[npm-url]: https://npmjs.org/package/simple-get\n[downloads-image]: https://img.shields.io/npm/dm/simple-get.svg\n[downloads-url]: https://npmjs.org/package/simple-get\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n### Simplest way to make http get requests\n\n## features\n\nThis module is the lightest possible wrapper on top of node.js `http`, but supporting these essential features:\n\n- follows redirects\n- automatically handles gzip/deflate responses\n- supports HTTPS\n- supports specifying a timeout\n- supports convenience `url` key so there's no need to use `url.parse` on the url when specifying options\n- composes well with npm packages for features like cookies, proxies, form data, & OAuth\n\nAll this in < 120 lines of code.\n\n## install\n\n```\nnpm install simple-get\n```\n\n## usage\n\nNote, all these examples also work in the browser with [browserify](http://browserify.org/).\n\n### simple GET request\n\nDoesn't get easier than this:\n\n```js\nconst get = require('simple-get')\n\nget('http://example.com', function (err, res) {\n  if (err) throw err\n  console.log(res.statusCode) // 200\n  res.pipe(process.stdout) // `res` is a stream\n})\n```\n\n### even simpler GET request\n\nIf you just want the data, and don't want to deal with streams:\n\n```js\nconst get = require('simple-get')\n\nget.concat('http://example.com', function (err, res, data) {\n  if (err) throw err\n  console.log(res.statusCode) // 200\n  console.log(data) // Buffer('this is the server response')\n})\n```\n\n### POST, PUT, PATCH, HEAD, DELETE support\n\nFor `POST`, call `get.post` or use option `{ method: 'POST' }`.\n\n```js\nconst get = require('simple-get')\n\nconst opts = {\n  url: 'http://example.com',\n  body: 'this is the POST body'\n}\nget.post(opts, function (err, res) {\n  if (err) throw err\n  res.pipe(process.stdout) // `res` is a stream\n})\n```\n\n#### A more complex example:\n\n```js\nconst get = require('simple-get')\n\nget({\n  url: 'http://example.com',\n  method: 'POST',\n  body: 'this is the POST body',\n\n  // simple-get accepts all options that node.js `http` accepts\n  // See: http://nodejs.org/api/http.html#http_http_request_options_callback\n  headers: {\n    'user-agent': 'my cool app'\n  }\n}, function (err, res) {\n  if (err) throw err\n\n  // All properties/methods from http.IncomingResponse are available,\n  // even if a gunzip/inflate transform stream was returned.\n  // See: http://nodejs.org/api/http.html#http_http_incomingmessage\n  res.setTimeout(10000)\n  console.log(res.headers)\n\n  res.on('data', function (chunk) {\n    // `chunk` is the decoded response, after it's been gunzipped or inflated\n    // (if applicable)\n    console.log('got a chunk of the response: ' + chunk)\n  }))\n\n})\n```\n\n### JSON\n\nYou can serialize/deserialize request and response with JSON:\n\n```js\nconst get = require('simple-get')\n\nconst opts = {\n  method: 'POST',\n  url: 'http://example.com',\n  body: {\n    key: 'value'\n  },\n  json: true\n}\nget.concat(opts, function (err, res, data) {\n  if (err) throw err\n  console.log(data.key) // `data` is an object\n})\n```\n\n### Timeout\n\nYou can set a timeout (in milliseconds) on the request with the `timeout` option.\nIf the request takes longer than `timeout` to complete, then the entire request\nwill fail with an `Error`.\n\n```js\nconst get = require('simple-get')\n\nconst opts = {\n  url: 'http://example.com',\n  timeout: 2000 // 2 second timeout\n}\n\nget(opts, function (err, res) {})\n```\n\n### One Quick Tip\n\nIt's a good idea to set the `'user-agent'` header so the provider can more easily\nsee how their resource is used.\n\n```js\nconst get = require('simple-get')\nconst pkg = require('./package.json')\n\nget('http://example.com', {\n  headers: {\n    'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)`\n  }\n})\n```\n\n### Proxies\n\nYou can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the\n`agent` option to work with proxies:\n\n```js\nconst get = require('simple-get')\nconst tunnel = require('tunnel')\n\nconst opts = {\n  url: 'http://example.com',\n  agent: tunnel.httpOverHttp({\n    proxy: {\n      host: 'localhost'\n    }\n  })\n}\n\nget(opts, function (err, res) {})\n```\n\n### Cookies\n\nYou can use the [`cookie`](https://github.com/jshttp/cookie) module to include\ncookies in a request:\n\n```js\nconst get = require('simple-get')\nconst cookie = require('cookie')\n\nconst opts = {\n  url: 'http://example.com',\n  headers: {\n    cookie: cookie.serialize('foo', 'bar')\n  }\n}\n\nget(opts, function (err, res) {})\n```\n\n### Form data\n\nYou can use the [`form-data`](https://github.com/form-data/form-data) module to\ncreate POST request with form data:\n\n```js\nconst fs = require('fs')\nconst get = require('simple-get')\nconst FormData = require('form-data')\nconst form = new FormData()\n\nform.append('my_file', fs.createReadStream('/foo/bar.jpg'))\n\nconst opts = {\n  url: 'http://example.com',\n  body: form\n}\n\nget.post(opts, function (err, res) {})\n```\n\n#### Or, include `application/x-www-form-urlencoded` form data manually:\n\n```js\nconst get = require('simple-get')\n\nconst opts = {\n  url: 'http://example.com',\n  form: {\n    key: 'value'\n  }\n}\nget.post(opts, function (err, res) {})\n```\n\n### OAuth\n\nYou can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create\na signed OAuth request:\n\n```js\nconst get = require('simple-get')\nconst crypto  = require('crypto')\nconst OAuth = require('oauth-1.0a')\n\nconst oauth = OAuth({\n  consumer: {\n    key: process.env.CONSUMER_KEY,\n    secret: process.env.CONSUMER_SECRET\n  },\n  signature_method: 'HMAC-SHA1',\n  hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')\n})\n\nconst token = {\n  key: process.env.ACCESS_TOKEN,\n  secret: process.env.ACCESS_TOKEN_SECRET\n}\n\nconst url = 'https://api.twitter.com/1.1/statuses/home_timeline.json'\n\nconst opts = {\n  url: url,\n  headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),\n  json: true\n}\n\nget(opts, function (err, res) {})\n```\n\n### Throttle requests\n\nYou can use [limiter](https://github.com/jhurliman/node-rate-limiter) to throttle requests. This is useful when calling an API that is rate limited.\n\n```js\nconst simpleGet = require('simple-get')\nconst RateLimiter = require('limiter').RateLimiter\nconst limiter = new RateLimiter(1, 'second')\n\nconst get = (opts, cb) => limiter.removeTokens(1, () => simpleGet(opts, cb))\nget.concat = (opts, cb) => limiter.removeTokens(1, () => simpleGet.concat(opts, cb))\n\nvar opts = {\n  url: 'http://example.com'\n}\n\nget.concat(opts, processResult)\nget.concat(opts, processResult)\n\nfunction processResult (err, res, data) {\n  if (err) throw err\n  console.log(data.toString())\n}\n```\n\n## license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).\n","publish_time":1643081033177,"_cnpm_publish_time":1643081033177,"dist-tags":{"latest":"4.0.1"}}