Skip to content

needlevswreck

MIT 83 4 1,631
53.5 million (month) Dec 11 2011 3.5.0(2026-03-12 22:24:55 ago)
378 7 4 BSD-3-Clause
Aug 06 2011 300.2 thousand (month) 18.1.0(2025-07-24 23:01:15 ago)

needle is an HTTP client library for Node.js that provides a simple, flexible, and powerful API for making HTTP requests. It supports all major HTTP methods and has a clean and easy-to-use interface for handling responses and errors.

Wreck is an HTTP client library for Node.js. It provides a simple, consistent API for making HTTP requests, including support for both the client and server side of an HTTP transaction.

Wreck is a very minimal but stable as it's part of Hapi web framework project. For web scraping, it doesn't offer required features like proxy configuration or http2 support so it's not recommended.

Example Use


```javascript const needle = require('needle'); // needle supports both Promises and async/await needle.get('https://httpbin.org/get', (err, res) => { if (err) { console.error(err); return; } console.log(res.body); }); const response = await needle.get('https://httpbin.org/get') // concurrent requests can be sent using Promise.all const results = await Promise.all([ needle.get('http://httpbin.org/html'), needle.get('http://httpbin.org/html'), needle.get('http://httpbin.org/html'), ]) // POST requests const data = { name: 'John Doe' }; await needle.post('https://api.example.com', data) // proxy const options = { proxy: 'http://proxy.example.com:8080' }; await needle.get('https://httpbin.org/ip', options) // headers and cookies const options = { headers: { 'Cookie': 'myCookie=123', 'X-My-Header': 'myValue' } }; await needle.get('https://httpbin.org/headers', options) ```
```javascript const Wreck = require('wreck'); // get request Wreck.get('http://example.com', (err, res, payload) => { if (err) { throw err; } console.log(payload.toString()); }); // post request const options = { headers: { 'content-type': 'application/json' }, payload: JSON.stringify({ name: 'John Doe' }) }; Wreck.post('http://example.com', options, (err, res, payload) => { if (err) { throw err; } console.log(payload.toString()); }); ```

Alternatives / Similar


Was this page helpful?