{"name":"simple-get","description":"Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.","version":"2.8.1","author":{"name":"Feross Aboukhadijeh","email":"feross@feross.org","url":"http://feross.org/"},"browser":{"decompress-response":false},"bugs":{"url":"https://github.com/feross/simple-get/issues"},"dependencies":{"decompress-response":"^3.3.0","once":"^1.3.1","simple-concat":"^1.0.0"},"devDependencies":{"self-signed-https":"^1.0.5","standard":"*","string-to-stream":"^1.0.0","tape":"^4.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"},"gitHead":"c0351df7dda5502b6c46728b06743f7b387cb6d7","_id":"simple-get@2.8.1","_npmVersion":"6.0.0","_nodeVersion":"8.11.1","_npmUser":{"name":"feross","email":"feross@feross.org"},"dist":{"integrity":"sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==","shasum":"0e22e91d4575d87620620bc91308d57a77f44b5d","tarball":"http://registry-npm.ywwl.com/simple-get/download/simple-get-2.8.1.tgz","fileCount":4,"unpackedSize":13021,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa35cuCRA9TVsSAnZWagAA4OUP/3hXnUIK2BDCbNNmYyMK\nEMegu24zC1vgFqv/ZSVrdspPKcylT/g5baQn2VlS4JGaHYvhxwricToESRg9\nnTqhTw/v5xtA7sSxz9in4M/36pHiwFJKb2C+MsVM5mq7q+aqHxIHeJ+GReQ3\ndRrwobSy9QySshSinG5Pu7uAr81SaAvajKyva/0+CM7o/1vSL+blC1/CY7WW\ni2xzEXAYAMw/u8SpSMPuccqiN5K2+267tem49kNLnSPxFidvfIkEQ9Umghkb\naNvHlKODGj405pyyarfEONDdT8pbDYw1xz7BIUzANsiPuHmdUlWIhm1m+kUL\nBn0YNZdusqAL4loSPwafjFYcb+3hly7LF3JQUxumfZpvoBLGv7os4Aw2IiDG\n4gbTCUT+2Ks8eGKj/SoXdEdQgsvkDtt3eBySbxy3oaHkw0o5uXomXIavEj0E\nFZOvYmvYKHXJmY+oQFLqR7g7j16fMLBuno3KfwYCxkjsQVSic56d+Xsz1OA0\nEV5y1tgfPWj745nFwM3m/eqD9suaZMBhLNQ5heMBIBM9KOK0dr7zuBINeAKv\nXXk7iMp2rOionQhn+4VVNeDU13kgB8369qmMZFsST1R8L6AuaIrOqWJBD2rA\nT++YICxd9wirtK/1HwLmKAgSkjidV0iRbBfJFYGkySIHPpKn+54RzNGHzLID\nU/Lc\r\n=uIpo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGcWWPqVJk7kV0grZupF8vtgMzGSpS09MuyfzRY5Nc+rAiBW1BN6X4+dtC+CLHO7UNi+dyRKkLAiwkCZIa5AYMbJMQ=="}],"size":4776,"noattachment":false,"key":"/simple-get/-/simple-get-2.8.1.tgz"},"maintainers":[{"name":"feross","email":"feross@feross.org"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/simple-get_2.8.1_1524602670094_0.5544670814451136"},"_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":1524602670196,"_cnpm_publish_time":1524602670196,"dist-tags":{"latest":"4.0.1"}}