{"id":48774,"library":"node-rest-api-client","title":"Node REST Client","description":"A simple-to-use HTTP REST API client for Node.js supporting GET, POST, PUT, DELETE, PATCH, and custom methods. Version 4.0.0 provides transparent HTTP/HTTPS connections, basic authentication, proxy support, dynamic path and query parameters, custom request serializers (JSON, XML, url-encoded), custom response parsers (JSON, XML), compressed response handling (gzip, deflate), and follow-redirects. It allows registering remote API operations as client methods. Latest stable release has irregular release cadence; key differentiator is its simple callback-based API without promises, but it lacks TypeScript support.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/theleapofcode/node-rest-client","tags":["javascript"],"install":[{"cmd":"npm install node-rest-api-client","lang":"bash","label":"npm"},{"cmd":"yarn add node-rest-api-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-rest-api-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Handles HTTP redirects transparently","package":"follow-redirects","optional":false},{"reason":"Provides XML response parsing when content-type is XML","package":"xml2js","optional":true}],"imports":[{"note":"CommonJS export is { Client } not default export. Requires require destructuring.","wrong":"const Client = require('node-rest-client');","symbol":"Client","correct":"const { Client } = require('node-rest-client');"},{"note":"Package is CJS only; ESM import works via interop but named import is correct.","wrong":"import Client from 'node-rest-client';","symbol":"Client (ESM)","correct":"import { Client } from 'node-rest-client';"},{"note":"Register methods before use; methods property contains all registered methods.","wrong":"","symbol":"Methods from client instance","correct":"client.registerMethod('myMethod', url, 'GET'); client.methods.myMethod(callback);"}],"quickstart":{"code":"const { Client } = require('node-rest-client');\n\nconst client = new Client();\n\n// Direct GET\nclient.get('https://jsonplaceholder.typicode.com/posts/1', function(data, response) {\n  console.log('Data:', data);\n  console.log('Response status:', response.statusCode);\n});\n\n// Registered method\nclient.registerMethod('getPost', 'https://jsonplaceholder.typicode.com/posts/${id}', 'GET');\nconst args = {\n  path: { id: 2 },\n  headers: { 'Accept': 'application/json' }\n};\nclient.methods.getPost(args, function(data, response) {\n  console.log('Registered method data:', data);\n});\n\n// POST example\nconst postArgs = {\n  data: { title: 'foo', body: 'bar', userId: 1 },\n  headers: { 'Content-Type': 'application/json' }\n};\nclient.post('https://jsonplaceholder.typicode.com/posts', postArgs, function(data, response) {\n  console.log('POST response:', data);\n});","lang":"javascript","description":"Shows direct GET, registered method with path substitution, and POST with JSON data and headers."},"warnings":[{"fix":"Always set 'Content-Type' header (e.g., 'application/json') in the headers argument for methods that send a body.","message":"POST, PUT, PATCH requests require 'Content-Type' header in args, otherwise they may fail or behave unexpectedly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use template literal-style placeholders in URL: 'http://example.com/resource/${id}' and pass { path: { id: value } }.","message":"When using registered methods, path parameters like ${id} must be provided in args.path, but the URL string must use '${}' syntax, not ':'.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use function(data, response) { ... } with data first, response second.","message":"The callback receives response as second argument, not first. Many users expect (response, data) order.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove followRedirects option; redirect handling is automatic.","message":"The option 'followRedirects' is deprecated; redirects are now always followed using the follow-redirects package.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Explicitly set headers: { 'Content-Type': 'application/json' } when sending JSON payloads.","message":"Default serializer for request data is 'application/x-www-form-urlencoded' when Content-Type is not set, even for POST with JSON objects.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'4.0.0':25 'allow':62 'api':11,65,85 'authent':31 'base':84 'basic':30 'cadenc':76 'callback':83 'callback-bas':82 'client':3,12,68 'compress':52 'connect':29 'custom':22,39,47 'deflat':56 'delet':19 'differenti':78 'dynam':34 'encod':46 'follow':59 'follow-redirect':58 'get':16 'gzip':55 'handl':54 'http':9 'http/https':28 'irregular':74 'javascript':93 'json':42,50 'key':77 'lack':90 'latest':70 'method':23,69 'node':1 'node.js':14 'oper':66 'paramet':38 'parser':49 'patch':20 'path':35 'post':17 'promis':87 'provid':26 'proxi':32 'put':18 'queri':37 'redirect':60 'regist':63 'releas':72,75 'remot':64 'request':40 'respons':48,53 'rest':2,10 'serial':41 'simpl':6,81 'simple-to-us':5 'stabl':71 'support':15,33,92 'transpar':27 'typescript':91 'url':45 'url-encod':44 'use':8 'version':24 'without':86 'xml':43,51","created_at":"2026-06-07T16:58:23.815087+00:00","updated_at":"2026-06-07T16:58:23.815087+00:00","problems":[{"fix":"Use const { Client } = require('node-rest-client');","cause":"Importing the package as default export instead of destructuring { Client }.","error":"TypeError: client.get is not a function"},{"fix":"Run npm install node-rest-client --save, which will install follow-redirects as a dependency.","cause":"Missing dependency when using npm versions that don't auto-install peer deps.","error":"Error: Cannot find module 'follow-redirects'"},{"fix":"Add headers: { 'Content-Type': 'application/json' } to the args object.","cause":"Missing or incorrect Content-Type header for POST/PUT/PATCH requests.","error":"The request body is empty or not sent"},{"fix":"Call client.registerMethod(name, url, verb) before accessing client.methods.name.","cause":"Accessing client.methods before registering any method or using unregistered method name.","error":"Cannot read property 'get' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/theleapofcode/node-rest-client#readme","github":"https://github.com/theleapofcode/node-rest-client","docs":null,"changelog":null,"pypi":null,"npm":"node-rest-api-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}