first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,18 @@
{
"node": "n8n-nodes-base.apiTemplateIo",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Marketing"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/apitemplateio/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.apitemplateio/"
}
]
}
}
@@ -0,0 +1,579 @@
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes, NodeOperationError } from 'n8n-workflow';
import {
apiTemplateIoApiRequest,
downloadImage,
loadResource,
validateJSON,
} from './GenericFunctions';
export class ApiTemplateIo implements INodeType {
description: INodeTypeDescription = {
displayName: 'APITemplate.io',
name: 'apiTemplateIo',
icon: 'file:apiTemplateIo.svg',
group: ['transform'],
version: 1,
description: 'Consume the APITemplate.io API',
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
defaults: {
name: 'APITemplate.io',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'apiTemplateIoApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Account',
value: 'account',
},
{
name: 'Image',
value: 'image',
},
{
name: 'PDF',
value: 'pdf',
},
],
default: 'image',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'create',
required: true,
options: [
{
name: 'Create',
value: 'create',
action: 'Create an image',
},
],
displayOptions: {
show: {
resource: ['image'],
},
},
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'create',
required: true,
options: [
{
name: 'Create',
value: 'create',
action: 'Create a pdf',
},
],
displayOptions: {
show: {
resource: ['pdf'],
},
},
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'get',
required: true,
options: [
{
name: 'Get',
value: 'get',
action: 'Get an account',
},
],
displayOptions: {
show: {
resource: ['account'],
},
},
},
{
displayName: 'Template Name or ID',
name: 'imageTemplateId',
type: 'options',
required: true,
default: '',
description:
'ID of the image template to use. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'getImageTemplates',
},
displayOptions: {
show: {
resource: ['image'],
operation: ['create'],
},
},
},
{
displayName: 'Template Name or ID',
name: 'pdfTemplateId',
type: 'options',
required: true,
default: '',
description:
'ID of the PDF template to use. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'getPdfTemplates',
},
displayOptions: {
show: {
resource: ['pdf'],
operation: ['create'],
},
},
},
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
type: 'boolean',
default: false,
displayOptions: {
show: {
resource: ['pdf', 'image'],
operation: ['create'],
},
},
},
{
displayName: 'Download',
name: 'download',
type: 'boolean',
default: false,
displayOptions: {
show: {
resource: ['pdf', 'image'],
operation: ['create'],
},
},
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description: 'Name of the binary property to which to write the data of the read file',
},
{
displayName: 'Put Output File in Field',
name: 'binaryProperty',
type: 'string',
required: true,
default: 'data',
hint: 'The name of the output binary field to put the file in',
displayOptions: {
show: {
resource: ['pdf', 'image'],
operation: ['create'],
download: [true],
},
},
},
{
displayName: 'Overrides (JSON)',
name: 'overridesJson',
type: 'json',
default: '',
displayOptions: {
show: {
resource: ['image'],
operation: ['create'],
jsonParameters: [true],
},
},
placeholder:
'[ {"name": "text_1", "text": "hello world", "textBackgroundColor": "rgba(246, 243, 243, 0)" } ]',
},
{
displayName: 'Properties (JSON)',
name: 'propertiesJson',
type: 'json',
default: '',
displayOptions: {
show: {
resource: ['pdf'],
operation: ['create'],
jsonParameters: [true],
},
},
placeholder: '{ "name": "text_1" }',
},
{
displayName: 'Overrides',
name: 'overridesUi',
placeholder: 'Add Override',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
resource: ['image'],
operation: ['create'],
jsonParameters: [false],
},
},
default: {},
options: [
{
name: 'overrideValues',
displayName: 'Override',
values: [
{
displayName: 'Properties',
name: 'propertiesUi',
placeholder: 'Add Property',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
options: [
{
name: 'propertyValues',
displayName: 'Property',
values: [
{
displayName: 'Key',
name: 'key',
type: 'string',
default: '',
description: 'Name of the property',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value to the property',
},
],
},
],
},
],
},
],
},
{
displayName: 'Properties',
name: 'propertiesUi',
placeholder: 'Add Property',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
default: {},
displayOptions: {
show: {
resource: ['pdf'],
operation: ['create'],
jsonParameters: [false],
},
},
options: [
{
name: 'propertyValues',
displayName: 'Property',
values: [
{
displayName: 'Key',
name: 'key',
type: 'string',
default: '',
description: 'Name of the property',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value to the property',
},
],
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
displayOptions: {
show: {
operation: ['create'],
resource: ['pdf', 'image'],
download: [true],
},
},
default: {},
options: [
{
displayName: 'File Name',
name: 'fileName',
type: 'string',
default: '',
description:
'The name of the downloaded image/pdf. It has to include the extension. For example: report.pdf',
},
],
},
],
};
methods = {
loadOptions: {
async getImageTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await loadResource.call(this, 'image');
},
async getPdfTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await loadResource.call(this, 'pdf');
},
},
};
async execute(this: IExecuteFunctions) {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const length = items.length;
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
if (resource === 'account') {
// *********************************************************************
// account
// *********************************************************************
if (operation === 'get') {
// ----------------------------------
// account: get
// ----------------------------------
for (let i = 0; i < length; i++) {
try {
responseData = await apiTemplateIoApiRequest.call(this, 'GET', '/account-information');
returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
continue;
}
throw error;
}
}
}
} else if (resource === 'image') {
// *********************************************************************
// image
// *********************************************************************
if (operation === 'create') {
// ----------------------------------
// image: create
// ----------------------------------
const download = this.getNodeParameter('download', 0);
// https://docs.apitemplate.io/reference/api-reference.html#create-an-image-jpeg-and-png
for (let i = 0; i < length; i++) {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i);
let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i);
}
const qs = {
template_id: this.getNodeParameter('imageTemplateId', i),
};
const body = { overrides: [] } as IDataObject;
if (!jsonParameters) {
const overrides =
((this.getNodeParameter('overridesUi', i) as IDataObject)
?.overrideValues as IDataObject[]) || [];
if (overrides.length !== 0) {
const data: IDataObject[] = [];
for (const override of overrides) {
const properties =
((override.propertiesUi as IDataObject)?.propertyValues as IDataObject[]) || [];
data.push(
properties.reduce(
(obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }),
{},
),
);
}
body.overrides = data;
}
} else {
const overrideJson = this.getNodeParameter('overridesJson', i) as string;
if (overrideJson !== '') {
const data = validateJSON(overrideJson);
if (data === undefined) {
throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', {
itemIndex: i,
});
}
body.overrides = data;
}
}
responseData = await apiTemplateIoApiRequest.call(this, 'POST', '/create', qs, body);
if (download) {
const binaryProperty = this.getNodeParameter('binaryProperty', i);
const data = await downloadImage.call(this, responseData.download_url as string);
const fileName = responseData.download_url.split('/').pop();
const binaryData = await this.helpers.prepareBinaryData(
data as Buffer,
(options.fileName as string) || (fileName as string),
);
responseData = {
json: responseData,
binary: {
[binaryProperty]: binaryData,
},
};
}
returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
continue;
}
throw error;
}
}
if (download) {
return [returnData as unknown as INodeExecutionData[]];
}
}
} else if (resource === 'pdf') {
// *********************************************************************
// pdf
// *********************************************************************
if (operation === 'create') {
// ----------------------------------
// pdf: create
// ----------------------------------
// https://docs.apitemplate.io/reference/api-reference.html#create-a-pdf
const download = this.getNodeParameter('download', 0);
for (let i = 0; i < length; i++) {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i);
let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i);
}
const qs = {
template_id: this.getNodeParameter('pdfTemplateId', i),
};
let data;
if (!jsonParameters) {
const properties =
((this.getNodeParameter('propertiesUi', i) as IDataObject)
?.propertyValues as IDataObject[]) || [];
if (properties.length === 0) {
throw new NodeOperationError(
this.getNode(),
'The parameter properties cannot be empty',
{ itemIndex: i },
);
}
data = properties.reduce(
(obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }),
{},
);
} else {
const propertiesJson = this.getNodeParameter('propertiesJson', i) as string;
data = validateJSON(propertiesJson);
if (data === undefined) {
throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', {
itemIndex: i,
});
}
}
responseData = await apiTemplateIoApiRequest.call(
this,
'POST',
'/create',
qs,
data as IDataObject,
);
if (download) {
const binaryProperty = this.getNodeParameter('binaryProperty', i);
const imageData = await downloadImage.call(this, responseData.download_url as string);
const fileName = responseData.download_url.split('/').pop();
const binaryData = await this.helpers.prepareBinaryData(
imageData as Buffer,
(options.fileName || fileName) as string,
);
responseData = {
json: responseData,
binary: {
[binaryProperty]: binaryData,
},
};
}
returnData.push(responseData as IDataObject);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
continue;
}
throw error;
}
}
if (download) {
return [returnData as unknown as INodeExecutionData[]];
}
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}
@@ -0,0 +1,87 @@
import type {
IExecuteFunctions,
ILoadOptionsFunctions,
JsonObject,
IRequestOptions,
IHttpRequestMethods,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function apiTemplateIoApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
qs = {},
body = {},
) {
const options: IRequestOptions = {
headers: {
'user-agent': 'n8n',
Accept: 'application/json',
},
uri: `https://api.apitemplate.io/v1${endpoint}`,
method,
qs,
body,
followRedirect: true,
followAllRedirects: true,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(qs).length) {
delete options.qs;
}
try {
const response = await this.helpers.requestWithAuthentication.call(
this,
'apiTemplateIoApi',
options,
);
if (response.status === 'error') {
throw new NodeApiError(this.getNode(), response.message as JsonObject);
}
return response;
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export async function loadResource(this: ILoadOptionsFunctions, resource: 'image' | 'pdf') {
const target = resource === 'image' ? ['JPEG', 'PNG'] : ['PDF'];
const templates = await apiTemplateIoApiRequest.call(this, 'GET', '/list-templates');
const filtered = templates.filter(({ format }: { format: 'PDF' | 'JPEG' | 'PNG' }) =>
target.includes(format),
);
return filtered.map(({ format, name, id }: { format: string; name: string; id: string }) => ({
name: `${name} (${format})`,
value: id,
}));
}
export function validateJSON(json: string | object | undefined): any {
let result;
if (typeof json === 'object') {
return json;
}
try {
result = JSON.parse(json!);
} catch (exception) {
result = undefined;
}
return result;
}
export async function downloadImage(this: IExecuteFunctions, url: string) {
return await this.helpers.request({
uri: url,
method: 'GET',
json: false,
encoding: null,
});
}
@@ -0,0 +1,21 @@
{
"type": "object",
"properties": {
"download_url": {
"type": "string"
},
"download_url_png": {
"type": "string"
},
"status": {
"type": "string"
},
"template_id": {
"type": "string"
},
"transaction_ref": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1,18 @@
{
"type": "object",
"properties": {
"download_url": {
"type": "string"
},
"status": {
"type": "string"
},
"template_id": {
"type": "string"
},
"transaction_ref": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 23.167 21.167"><path fill="#91bce5" d="M18.611.504 3.473 11.24l4.597 2.213 1.066 3.883 3.171-2.226 2.802.951z"/><path fill="#1f212b" d="M9.172 17.597a.264.264 0 0 1-.29-.192l-1.035-3.767-4.488-2.16a.265.265 0 0 1-.039-.454L18.458.288a.264.264 0 0 1 .41.274l-3.5 15.556a.265.265 0 0 1-.344.193l-2.674-.908-3.061 2.15a.3.3 0 0 1-.117.044m-5.18-6.401 4.193 2.017c.069.034.12.095.14.169l.967 3.52 2.863-2.01a.27.27 0 0 1 .237-.033l2.524.856L18.2 1.119z"/><path fill="#3a84c1" d="m9.339 17.079.946-2.913L18.642.728 8.226 13.235z"/><path fill="#1f212b" d="M9.356 17.21a.132.132 0 0 1-.143-.172l.946-2.913.014-.03 7.393-11.888-9.419 11.156a.133.133 0 0 1-.202-.171L18.54.642a.132.132 0 0 1 .214.156l-8.348 13.424-.941 2.898a.13.13 0 0 1-.109.09m-3.215 1.045c-1.168.029-2.303-.373-3.067-1.287-.485-.58-.683-1.574.275-1.705.859-.119 1.229.485 1.48 1.196.804 2.026.16 2.938-1.68 4.272-.144.09.015.296.159.206 1.218-1 1.829-1.466 2.1-2.448.134-1.36-.402-3.091-1.384-3.436-1.12-.382-2.063.516-1.499 1.585.699 1.324 2.23 1.914 3.652 1.878.17-.004.133-.266-.036-.261"/><path fill="#1f212b" d="M7.235 18.14a15 15 0 0 1-.759.09c-.17.017-.133.279.036.262.253-.025.507-.052.758-.09.169-.026.133-.288-.035-.262m1.194-.504a9 9 0 0 1-.865.344c-.162.054-.057.297.104.243a8 8 0 0 0 .865-.344c.154-.071.05-.315-.104-.243"/><path d="M12.599 15.22a.13.13 0 0 1-.07-.01l-2.168-.924a.133.133 0 0 1 .103-.243l2.169.923a.133.133 0 0 1-.034.253z"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB