2023-01-27 03:22:44 -08:00
|
|
|
import type {
|
2022-09-27 02:05:51 -07:00
|
|
|
IAuthenticateGeneric,
|
|
|
|
ICredentialTestRequest,
|
|
|
|
ICredentialType,
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class N8nApi implements ICredentialType {
|
|
|
|
name = 'n8nApi';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-27 02:05:51 -07:00
|
|
|
displayName = 'n8n API';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-12-22 06:33:34 -08:00
|
|
|
documentationUrl = 'https://docs.n8n.io/api/authentication/';
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-27 02:05:51 -07:00
|
|
|
properties: INodeProperties[] = [
|
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
|
|
|
type: 'string',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
2022-09-27 02:05:51 -07:00
|
|
|
default: '',
|
|
|
|
description: 'The API key for the n8n instance',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Base URL',
|
|
|
|
name: 'baseUrl',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
placeholder: 'https://<name>.app.n8n.cloud/api/v1',
|
|
|
|
description: 'The API URL of the n8n instance',
|
|
|
|
},
|
|
|
|
];
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-27 02:05:51 -07:00
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
|
|
|
properties: {
|
|
|
|
headers: {
|
|
|
|
'X-N8N-API-KEY': '={{ $credentials.apiKey }}',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2022-12-02 12:54:28 -08:00
|
|
|
|
2022-09-27 02:05:51 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{ $credentials.baseUrl }}',
|
|
|
|
url: '/workflows?limit=5',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|