{"id":16528,"library":"sendgrid-rest","title":"Generic Node.js REST Client","description":"sendgrid-rest is a lightweight, generalized HTTP REST client library designed for Node.js environments. It provides a simplified, callback-based interface for making HTTP requests to any RESTful or RESTful-like API, abstracting away some of Node.js's native `http`/`https` module complexities. The package is currently at version 2.6.1, with the last release dating back to March 2020. Releases have been infrequent and focused on maintenance, documentation, and minor dependency updates (TypeScript type definitions were added in v2.6.0). This library is explicitly *not* the official SendGrid API client; for SendGrid-specific interactions, users are directed to the `@sendgrid/client` package. Its core design uses traditional CommonJS modules and callback patterns, reflecting its age, and it officially supported very old Node.js versions (0.10, 0.12, 4).","status":"abandoned","version":"2.6.1","language":"javascript","source_language":"en","source_url":"git://github.com/sendgrid/nodejs-http-client","tags":["javascript"],"install":[{"cmd":"npm install sendgrid-rest","lang":"bash","label":"npm"},{"cmd":"yarn add sendgrid-rest","lang":"bash","label":"yarn"},{"cmd":"pnpm add sendgrid-rest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This library is CommonJS-only and does not support ES modules. Direct destructuring of `require('sendgrid-rest')` is also common for `Client`.","wrong":"import { Client } from 'sendgrid-rest';","symbol":"Client","correct":"const Client = require('sendgrid-rest').Client;"},{"note":"TypeScript type definitions for `Client` were added in v2.6.0. Use `import type` for type-only imports to prevent accidental runtime imports in some bundlers.","wrong":"import { Client } from 'sendgrid-rest'; // When only importing types","symbol":"Client","correct":"import type { Client } from 'sendgrid-rest';"},{"note":"The `Request` object structure is an important type for defining HTTP calls with this client. It is used as a type, not a runtime value.","symbol":"Request (type)","correct":"import type { Request } from 'sendgrid-rest';"}],"quickstart":{"code":"const Client = require('sendgrid-rest').Client;\nconst client = new Client();\nconst request = client.emptyRequest();\nconst param = 'myparam';\n\nrequest.host = 'api.example.com';\nrequest.headers['Authorization'] = 'Bearer XXXXXX'; // Replace XXXXXX with your actual token\nrequest.queryParams['limit'] = 100;\nrequest.queryParams['offset'] = 0;\nrequest.method = 'POST';\nrequest.path = '/your/api/' + param + '/call';\n\nconst requestBody = {\n  'some': 0,\n  'awesome': 1,\n  'data': 3\n};\nrequest.body = requestBody;\n\nclient.API(request, function (response) {\n  console.log('Status Code:', response.statusCode);\n  console.log('Response Body:', response.body);\n  console.log('Response Headers:', response.headers);\n\n  if (response.statusCode >= 400) {\n    console.error('API Error:', response.body);\n  }\n});","lang":"javascript","description":"Demonstrates how to make a POST request to a hypothetical REST API, including setting headers, query parameters, and a JSON request body using the callback-based API."},"warnings":[{"fix":"Migrate your usage to the `@sendgrid/client` package, which offers a Promise-based API and is actively maintained. Install with `npm install @sendgrid/client`.","message":"The `sendgrid-rest` repository is explicitly no longer maintained by SendGrid. Users are advised to migrate to `@sendgrid/client` (part of the `sendgrid-nodejs` monorepo) for active development, support, and modern features.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"It is strongly recommended to migrate to a modern, actively maintained HTTP client library (like `axios`, `node-fetch`, or `@sendgrid/client`) that explicitly supports your Node.js version. If forced to use, thoroughly test against your target Node.js runtime.","message":"This library officially supports very old Node.js versions (0.10, 0.12, 4). Using it with modern Node.js versions (e.g., Node 16+) may lead to compatibility issues, unexpected behavior, or security vulnerabilities due to underlying system changes or unpatched dependencies.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider migrating to an HTTP client that offers native Promise support for better async control and cleaner code with `async/await`. Manual promisification is possible but adds boilerplate.","message":"The API uses a traditional Node.js callback pattern, which can lead to 'callback hell' in complex asynchronous flows and does not integrate naturally with modern `Promise`-based or `async/await` patterns. Error handling is also tied to this callback.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"If using SendGrid's email service, ensure your SendGrid account is on a paid plan to continue sending emails. This warning is specific to SendGrid API usage, not the `sendgrid-rest` library itself.","message":"While `sendgrid-rest` is a generic HTTP client, many users might encounter it searching for SendGrid API integration. SendGrid officially discontinued its free email plan as of July 26, 2025. This means any SendGrid API calls (regardless of client library) made from accounts on the free tier will fail.","severity":"deprecated","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure you are using `const Client = require('sendgrid-rest').Client;` in CommonJS contexts. If using TypeScript with `esModuleInterop` enabled, configure your `tsconfig.json` or adjust import paths. For modern applications, migrating to `@sendgrid/client` or another ESM-compatible HTTP client is recommended.","cause":"This error typically occurs in environments (like modern bundlers or TypeScript projects) attempting to import a CommonJS-only library using ES module `import` syntax.","error":"TypeError: sendgrid_rest__WEBPACK_IMPORTED_MODULE_0__.Client is not a constructor"},{"fix":"Update your Node.js environment to a more recent, officially supported LTS version. Ensure your system's certificate authorities are up to date. If behind a corporate proxy, configure Node.js to trust the proxy's certificates (`NODE_TLS_REJECT_UNAUTHORIZED=0` is a workaround but insecure for production).","cause":"Older Node.js versions or outdated SSL/TLS configurations in the underlying HTTP client can struggle with modern certificate chains, especially in corporate networks or when interacting with newer APIs.","error":"Error: unable to get local issuer certificate (or similar SSL/TLS error)"},{"fix":"Verify `request.host` and `request.path` are correct. Check network connectivity to the target API. Inspect server logs if you control the API. Implement robust error handling within the callback function and consider adding manual timeouts if the client doesn't provide them.","cause":"This indicates network issues, a slow or unresponsive API server, or incorrect `request.host` or `request.path` configuration preventing the HTTP request from completing or reaching its destination.","error":"Callback function not invoked / Request timed out"}],"ecosystem":"npm"}