{"id":26315,"library":"restler-base","title":"restler-base","description":"restler-base is a fork of the unmaintained restler HTTP client library for Node.js, version 3.4.6. It incorporates pending pull requests and fixes from the original project, serving as the foundation for restler-promise. The library provides an event-based API for making HTTP requests with automatic serialization of post data and query strings, transparent handling of SSL, redirects, gzip/deflate, and basic auth, plus automatic deserialization of XML, JSON, and YAML responses. It supports multipart file uploads and custom deserializers. Compared to modern alternatives like axios or node-fetch, restler-base is older and uses an event-driven pattern rather than promises, though it can be wrapped with restler-promise. Release cadence is low; last release was 3.4.6. Key differentiator: it is a maintained fork of restler, preserving its specific API for legacy projects.","status":"maintenance","version":"3.4.6","language":"javascript","source_language":"en","source_url":"https://github.com/mwittig/restler-base","tags":["javascript"],"install":[{"cmd":"npm install restler-base","lang":"bash","label":"npm"},{"cmd":"yarn add restler-base","lang":"bash","label":"yarn"},{"cmd":"pnpm add restler-base","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Automatic charset decoding for responses","package":"iconv-lite","optional":true},{"reason":"XML response deserialization","package":"xml2js","optional":true},{"reason":"YAML response deserialization","package":"yamljs","optional":true}],"imports":[{"note":"ESM works, but restler-base uses CommonJS internally. Default import works in both ESM and CJS.","wrong":"const restler = require('restler-base')","symbol":"restler","correct":"import restler from 'restler-base'"},{"note":"Do not import from 'restler' as that is the unmaintained original. Use 'restler-base'.","wrong":"import { request } from 'restler'","symbol":"request","correct":"import { request } from 'restler-base'"},{"note":"All methods (get, post, put, del) are named exports from the main package, not subpath exports.","wrong":"import get from 'restler-base/get'","symbol":"get","correct":"import { get, post, put, del } from 'restler-base'"}],"quickstart":{"code":"import restler from 'restler-base';\n\nrestler.get('https://api.example.com/data', {\n  headers: { 'Accept': 'application/json' },\n  timeout: 5000\n}).on('complete', (result, response) => {\n  if (result instanceof Error) {\n    console.error('Error:', result.message);\n  } else {\n    console.log('Data:', result);\n  }\n});\n\nrestler.post('https://api.example.com/submit', {\n  data: { name: 'test', value: 123 },\n  headers: { 'Content-Type': 'application/json' }\n}).on('success', (data, response) => {\n  console.log('Posted successfully:', data);\n}).on('fail', (data, response) => {\n  console.error('Failed with status:', response.statusCode);\n});","lang":"typescript","description":"Demonstrates basic HTTP GET and POST using the event-based API with error handling via 'complete' and 'success'/'fail' events."},"warnings":[{"fix":"Always check 'result instanceof Error' in 'complete' event handler before using result.","message":"The 'complete' event fires even on errors, and the first argument is an Error instance on failure. Always check if result instanceof Error.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using the restler-promise wrapper for promise-based API, or migrate to axios.","message":"Library uses a callback/event-driven pattern; newer projects should consider axios or node-fetch with promise support.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Install optional dependencies: npm install xml2js yamljs","message":"Automatic XML/YAML deserialization requires optional dependencies (xml2js, yamljs). Without them, responses will be strings.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always set timeout option to a reasonable value (e.g., 10000).","message":"The 'timeout' option is in milliseconds; if not set, requests may hang indefinitely.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Format multipart data as { file: { file: '/path/to/file', name: 'fieldname' } }.","message":"When using 'multipart: true', you must provide a 'data' object containing file properties with 'file' and 'name' sub-fields.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'3.4.6':20,128 'altern':90 'api':47,141 'auth':69 'automat':53,71 'axio':92 'base':3,6,46,99 'basic':68 'cadenc':122 'client':15 'compar':87 'custom':85 'data':57 'deseri':72,86 'differenti':130 'driven':107 'event':45,106 'event-bas':44 'event-driven':105 'fetch':96 'file':82 'fix':27 'fork':9,135 'foundat':35 'gzip/deflate':66 'handl':62 'http':14,50 'incorpor':22 'javascript':145 'json':75 'key':129 'last':125 'legaci':143 'librari':16,41 'like':91 'low':124 'maintain':134 'make':49 'modern':89 'multipart':81 'node':95 'node-fetch':94 'node.js':18 'older':101 'origin':30 'pattern':108 'pend':23 'plus':70 'post':56 'preserv':138 'project':31,144 'promis':39,111,120 'provid':42 'pull':24 'queri':59 'rather':109 'redirect':65 'releas':121,126 'request':25,51 'respons':78 'restler':2,5,13,38,98,119,137 'restler-bas':1,4,97 'restler-promis':37,118 'serial':54 'serv':32 'specif':140 'ssl':64 'string':60 'support':80 'though':112 'transpar':61 'unmaintain':12 'upload':83 'use':103 'version':19 'wrap':116 'xml':74 'yaml':77","created_at":"2026-05-01T13:49:20.354165+00:00","updated_at":"2026-05-01T13:49:20.354165+00:00","problems":[{"fix":"Run 'npm install restler-base' and ensure import is from 'restler-base' not 'restler'.","cause":"Package not installed or imported from wrong package name.","error":"Cannot find module 'restler-base'"},{"fix":"Check URL and options, ensure function returns a RestRequest object before chaining .on()","cause":"Forgetting to call a method like get() or post() returns a request object, but if URL is invalid or options cause immediate error, may return undefined.","error":"TypeError: Cannot read property 'on' of undefined"},{"fix":"Ensure target server is running, or use a valid URL.","cause":"No server listening on the target host/port (e.g., localhost test server not started).","error":"Error: connect ECONNREFUSED 127.0.0.1:80"},{"fix":"Use .once() instead of .on() if listeners should fire only once, or manage listener removal with .removeListener().","cause":"Adding many listeners on the same request object without removing or using once.","error":"Warning: Possible EventEmitter memory leak detected. 11 complete listeners added."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mwittig/restler-base","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/restler-base","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}