restler
raw JSON → 3.4.0 verified Sat Apr 25 auth: no javascript maintenance
An HTTP client library for Node.js (v3.4.0) that simplifies making HTTP requests with automatic serialization of POST data, query strings, and deserialization of XML, JSON, and YAML responses. It handles redirects, multipart file uploads, SSL, basic auth, content-encoding (gzip, deflate), and charset via iconv-lite. Compared to modern alternatives like axios or node-fetch, restler is older, less actively maintained, and uses an event-based API that can lead to memory leaks if not managed properly. It supports Node >= 0.10.x, with limited maintenance; version 3.4.0 is the latest, with no major updates since 2015.
Common errors
error Cannot find module 'restler' ↓
cause Package not installed.
fix
Run 'npm install restler'.
error TypeError: restler.get is not a function ↓
cause Incorrect import (ESM style used).
fix
Use 'const restler = require('restler');' instead of import.
Warnings
gotcha Events 'complete', 'success', 'fail' etc. are emitted on the request object; forgetting to attach listeners may cause unhandled events or memory leaks. ↓
fix Always attach 'error' or 'complete' listeners and handle errors properly.
deprecated The package is effectively deprecated; no updates since 2015 and not compatible with modern Node.js features. ↓
fix Consider migrating to axios, node-fetch, or got.
gotcha Automatic parsing of XML/YAML depends on optional dependencies that may not be installed. ↓
fix Install xml2js, yaml, etc. if needed, or disable parsing.
Install
npm install restler yarn add restler pnpm add restler Imports
- restler wrong
const restler = require('restler');correctimport restler from 'restler'
Quickstart
const restler = require('restler');
restler.get('https://api.example.com/data', {
username: 'user',
password: process.env.PASS ?? ''
}).on('complete', (data, response) => {
if (data instanceof Error) {
console.error('Error:', data.message);
} else {
console.log('Data:', data);
}
});