Create your own n8n custom node
Build a custom n8n node that fetches a cryptocurrency price from the Binance public API. This guide walks through a complete workflow: prepare a self-hosted n8n environment, create the required custom folder, scaffold a node project, implement a simple TypeScript node, build and deploy it into n8n, and test it in a workflow. I keep the implementation minimal and focused so you can extend it later with authentication, more operations, or additional resources.
Prerequisites
- Git installed
- Docker Desktop installed and running
- Basic familiarity with TypeScript and the n8n node structure
1. Start with the n8n self-hosted AI starter kit
Clone the starter kit repository into a project folder, follow the readme to pick the installation profile that matches your machine (CPU-only for most Windows PCs), and run the provided Docker command to start the stack. The first run will download images and perform configuration and can take a while depending on your connection and hardware.
After the first run, update the environment variables in the starter kit so future runs are more convenient and provide helpful logging:
- N8N_LOG_LEVEL = debug
- N8N_RUNNERS_ENABLED = true
- N8N_ENFORCE_FILE_PERMISSIONS = false
Re-run the Docker command after applying those env changes. It should now start faster and provide debug output if anything goes wrong.
2. Create the custom folder inside the n8n container
n8n looks for custom nodes in a custom folder inside the n8n home directory. That folder does not exist by default in the container, so create it.
# List running containers
docker ps
# Open a shell in the n8n container (replace with yours)
docker exec -it /bin/sh
# Create the custom folder
cd /home/node/.n8n
mkdir custom
pwd
# Expected: /home/node/.n8n/custom
# Exit the container shell
exit3. Scaffold an n8n node project
Use the official n8n node starter repository as a base. Clone it and rename the folder to start with n8n-nodes- if you plan to publish later as a community node.
git clone https://github.com/n8n-io/n8n-nodes-starter.git n8n-nodes-b24-custom-nodes
cd n8n-nodes-b24-custom-nodesEdit package.json to personalize the package:
- Replace the placeholder GitHub account with your own
- Change the package name to
n8n-nodes-b24-custom-nodes - Optionally set
homepage, description and other metadata
4. Install build tools and dependencies
I use pnpm for building. Install pnpm and utils like rimraf globally, then install project dependencies.
# Install global tools
npm install -g pnpm rimraf
# Install project dependencies
pnpm install5. Build and deploy your custom nodes into the container
Create a simple build-and-deploy script that runs the build, copies the generated dist files into the /home/node/.n8n/custom folder in the container, and restarts the n8n container.
# Example manual steps (your script can wrap these)
pnpm run build
# Copy built files into the container
docker cp ./dist :/home/node/.n8n/custom
# Restart n8n container to load the new node(s)
docker restart After copying, open a shell into the container to confirm the dist files are present under the custom folder.
6. Implementing the B24 Crypto Manager node
For a minimal custom node that reads a Binance price endpoint (no API key required), copy the example node folder and adapt the TypeScript file. The implementation below outlines the key changes I made:
- Rename the folder and TypeScript file to b24CryptoManager (file
B24CryptoManager.node.ts). Use a class name such as B24CryptoManager. - Change the node group to input and set a concise description and defaults.
- Remove the example execute function if you prefer to implement a declarative or smaller programmatic node. For simplicity this node will perform an HTTP GET to the Binance price endpoint.
- Add
requestDefaultswith base URL and headers to keep requests consistent. - Define one resource and one operation; add a symbol property (string) with default BTCUSDT.
- Add an SVG icon and reference it in the node metadata.
Example of the properties block inside a node TypeScript file:
properties: [
{
displayName: 'Symbol',
name: 'symbol',
type: 'string',
default: 'BTCUSDT',
description: 'Trading pair symbol (e.g. BTCUSDT, ETHUSDT)',
},
// Add more properties if needed
],Configure request defaults to point to the Binance API:
requestDefaults = {
baseURL: 'https://api.binance.com',
headers: {
'Content-Type': 'application/json',
},
};When executing the node programmatically, construct the request path using the provided symbol parameter. For the Binance price endpoint you can call:
GET /api/v3/ticker/price?symbol=BTCUSDT7. Register the node in package.json
Under the n8n section in package.json, add your node to the nodes list so n8n will load it from the package build.
8. Build, deploy and verify in n8n
- Run your build-and-deploy script so the dist artifacts are copied into the container custom folder.
- Open your n8n instance (default port used by the starter kit is 5678) and create a new workflow with a Manual Trigger.
- Add your custom node by searching for the node name (e.g. B24 Crypto Manager) and configure the symbol parameter or leave the default.
- Execute the node — the price result returns as JSON and appears like any other node output in n8n.
Make the node input dynamic
To feed the node dynamically from a previous step, add a Set node before the custom node and define a field named symbol with value ETHUSDT (or any trading pair).
Use the expression from the Set node in your custom node parameter. For example:
{{$node["Set"].json["symbol"]}}Execute the workflow and the custom node will fetch the price for Ethereum instead of Bitcoin.
9. Learnings, references and next steps
- Study existing n8n node implementations (for example CoinGecko) in the n8n GitHub repository to see both declarative-style and programmatic-style nodes.
- Use the n8n documentation to understand how to implement credentials if a public API requires authentication.
- If you plan to publish the node as a community node, ensure the package name starts with n8n-nodes- and follow the publishing guidelines.
- Next logical enhancements: add support for additional operations (historical price, candlesticks), error handling, retries, and optional credentials for private APIs.
Tips and troubleshooting
- If n8n does not show the new node after deployment, restart the container and check the n8n logs for errors.
- Use N8N_LOG_LEVEL=debug for more actionable debug output while developing nodes.
- Keep your build script idempotent: remove old files, copy fresh
distcontents, and restart the container. - For Windows users, the deployment script can be more complex; adapt commands to PowerShell or use WSL for a Unix-like environment.
You now have a working custom n8n node that retrieves live crypto prices from Binance and is integrated into an n8n workflow. Expand it with additional operations, authentication, and robust error handling as your needs evolve.
Free Stuff! |
|
Check out this really cool thing |
| Click me |