UNPKG

2.51 kBMarkdownView Raw
1<p align="center" style="text-align: center"><img src="https://raw.githubusercontent.com/ethanent/phin/master/media/phin-textIncluded.png" width="250" alt="phin logo"/></p>
2
3---
4
5> The ultra-lightweight Node.js HTTP client
6
7[Full documentation](https://ethanent.github.io/phin/) | [GitHub](https://github.com/ethanent/phin) | [NPM](https://www.npmjs.com/package/phin)
8
9
10## Simple Usage
11
12```javascript
13const p = require('phin')
14
15const res = await p('https://ethanent.me')
16
17console.log(res.body)
18```
19
20Note that the above should be in an async context! phin also provides an unpromisified version of the library.
21
22## Install
23
24```
25npm install phin
26```
27
28
29## Why phin?
30
31phin is **trusted** by some really important projects. The hundreds of contributors at [Less](https://github.com/less/less.js), for example, depend on phin as part of their development process.
32
33Also, phin is super **lightweight**. Like **99.8% smaller than request** lightweight. To compare to other libraries, see [phin vs. the Competition](https://github.com/ethanent/phin/blob/master/README.md#phin-vs-the-competition).
34
35<img src="https://pbs.twimg.com/media/DSPF9TaUQAA0tIe.jpg:large" alt="phin became 33% lighter with release 2.7.0!"/>
36
37
38## Quick Demos
39
40Simple POST:
41
42```javascript
43await p({
44 url: 'https://ethanent.me',
45 method: 'POST',
46 data: {
47 hey: 'hi'
48 }
49})
50```
51
52## Unpromisified Usage
53
54```javascript
55const p = require('phin').unpromisified
56
57p('https://ethanent.me', (err, res) => {
58 if (!err) console.log(res.body)
59})
60```
61
62Simple parsing of JSON:
63
64```javascript
65// (In async function in this case.)
66
67const res = await p({
68 url: 'https://ethanent.me/name',
69 parse: 'json'
70})
71
72console.log(res.body.first)
73```
74
75
76## Full Documentation
77
78See [the phin documentation](https://ethanent.github.io/phin/).
79
80## phin vs. the Competition
81
82<img src="https://pbs.twimg.com/media/DSLU_UcUEAI4bgc.jpg:large" alt="Request is over 6MB in size. phin is just 25KB in size."/>
83
84phin is a very lightweight library.
85
86It contains all of the common HTTP client features included in competing libraries!
87
88Package | Size (KB) | Dependencies<br />(Tree Count) | Size Comparison<br />(vs. phin)
89--- | --- | --- | ---
90request | 4,446 | [53](http://npm.anvaka.com/#/view/2d/request) | 444.6x
91superagent | 1,235 | [24](http://npm.anvaka.com/#/view/2d/superagent) | 123.5x
92got | 664 | [44](http://npm.anvaka.com/#/view/2d/got) | 66.4x
93snekfetch | 107 | [0](http://npm.anvaka.com/#/view/2d/snekfetch) | 10.7x
94phin | 10 | [1](http://npm.anvaka.com/#/view/2d/phin) | 1x
\No newline at end of file