NRest is an unofficial REST API for n8n®, written in C using Ulfius and SQLite.
This project tries to imitate the same functionality of the official n8n API, hosted in api.n8n.io, but with limited features.
The main goal is to provide custom n8n workflow templates using my own endpoint while being lightweight in memory usage.
Note: this is an experimental project. Please do not run it in production critical businesses, since I do not offer any support. You may want to consider strapi (since the official n8n API uses it) before using this.
Tested against version 1.107.4, I cannot make sure whether earlier versions or later versions were or will be supported since the n8n API is subject to change.
Install these packages on Debian/Ubuntu-based systems:
sudo apt update && sudo apt install -y \
build-essential \
libulfius-dev \
libjansson-dev \
libsqlite3-devOptionally, for the test suite, the Unity testing framework is used. No Debian package exists, so you may need to compile it yourself.
To build the project, run the following command:
make debugOptionally, you may want to use watchexec to automatically rebuild on changes:
watchexec -e c -- make debugTo build the project in release mode, run the following command:
make releaseTo run the project, regardless of the build mode:
make runTo test the project, regardless of the build mode:
make testThe following endpoints are implemented:
GET /health-- Check if the API is running.GET /templates/categories-- Retrieve all workflow categories.GET /templates/collections-- Retrieve all workflow collections.GET /templates/collections/:id-- Get a specific collection by ID.GET /templates/search-- Search for workflow templates.GET /templates/workflows-- Retrieve all workflow templates.GET /templates/workflows/:id-- Get a specific workflow template by ID.
CORS Preflight Support is also implemented via the OPTIONS header:
OPTIONS /templates/categoriesOPTIONS /templates/collectionsOPTIONS /templates/collections/:idOPTIONS /templates/searchOPTIONS /templates/workflowsOPTIONS /templates/workflows/:id
The following internal endpoints are implemented:
GET /workflows/templates/:id-- Get a specific workflow template by ID.
For easy of use, the following custom endpoints are implemented:
PUT /templates/workflows-- Create new workflow.PUT /templates/collections-- Create new collection of workflows.PATCH /templates/collections-- Insert new template workflow into a collection.
You can test endpoints using curl or any other HTTP client.
curl http://localhost:8080/workflowsThe following samples are provided:
- Database samples: You may want to run
scripts/test-data.shwhile the REST API server is running in order to insert custom sample data. - Unit testing samples (from upstream): You may want to look at the mock directory (you may need to run
make setup-mocksfirst).627Xare sample workflows and6270_imported.jsonis used for testing the internal endpoint.n8n-api-collections.jsonis used for checking collection JSON structure. - Configuration samples: An NGINX and systemd sample configuration files are provided in the conf folder. You may want to replace @SERVER_NAME@ by your REST API server name and @N8N_SERVER_NAME@ by your N8N server name. Certbot must also be installed and configured in your server.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome. You may want to take a look at the TODO file.
n8n® is a registered trademark. This project is not affiliated with or endorsed by to n8n or n8n.io in any way. This is an independent implementation for educational and interoperability purposes only.