Docs/Integrations/Node-RED

Node-RED

Installing the APIVerve node from the palette, setting the key, and calling any API from a flow with msg.payload.

The @apiverve/node-red-apiverve package adds one apiverve node to Node-RED. It calls any API in the catalog: pick the API in the node, send its parameters in msg.payload, and the result comes back as msg.payload.

@apiverve/node-red-apiverve in the Flow Library

Installing

From the editor. Menu → Manage palette → Install, search for @apiverve/node-red-apiverve and install. The node appears in the network section.

npm. From your Node-RED user directory (usually ~/.node-red), then restart Node-RED:

bash
npm install @apiverve/node-red-apiverve

Docker. The official image keeps its user directory in /data, so install there:

bash
docker exec -it mynodered npm install --prefix /data @apiverve/node-red-apiverve
docker restart mynodered

Requires Node-RED 3.0 or later and Node.js 18 or later.

Setting the key

Open the node, add an Account and paste your API key. Node-RED stores it as a credential, so it is not included when you export or share a flow.

Leave the key empty to read it from the APIVERVE_API_KEY environment variable instead, which suits Docker and other hosted setups. See security for where credentials should live.

The shortest working flow

An inject node, the apiverve node set to Email Validator, and a debug node. Set the inject payload to a string:

text
support@myspace.com

A plain value fills the API's only required parameter, so this calls /v1/emailvalidator?email=support@myspace.com. The debug panel shows the data object from the response. The same flow ships with the package: Menu → Import → Examples → @apiverve/node-red-apiverve → validate-an-email.

Sending parameters

For anything with more than one parameter, send an object. A function node in front of the apiverve node works well:

js
msg.payload = { ip: msg.req.ip };   // e.g. from an http in node
return msg;

Parameters merge in this order, later ones winning:

  1. The Parameters field in the node (JSON), for values that never change.
  2. msg.payload.
  3. msg.params, for adding a value without replacing the payload.

The editor lists each API's parameters under the picker, and each API's reference page has the full set, for example Email Validator.

Choosing the API at runtime

Set msg.api to an API id to override the node's choice. One node can then serve several lookups:

js
msg.api = 'iplookup';
msg.payload = { ip: '8.8.8.8' };
return msg;

Output

Property
msg.payloadThe API's data object. Set Output to Full response to get status, error and data
msg.statusCodeThe HTTP status
msg.apiverve{ api, remainingCredits }, the credits left on your plan

The node's status line shows the API and your remaining credits after each call.

Errors and credits

Each message is one API request and uses that API's credits. A failed call goes to a catch node with msg.statusCode set, and the status line turns red:

  • 401: the key is missing, invalid or expired.
  • 403: the key is valid but not allowed to make this call (key scoping or an IP allow-list).
  • 429: rate-limited, or out of credits for the month.

The key is sent only to api.apiverve.com, and redirects are refused.

Source: github.com/apiverve/node-red-apiverve.

Was this page helpful?

Last updated