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,83 @@
import type {
IDataObject,
IExecuteFunctions,
IHookFunctions,
ILoadOptionsFunctions,
JsonObject,
IRequestOptions,
IHttpRequestMethods,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
function resolveHeaderData(fullResponse: any) {
if (fullResponse.statusCode === 201) {
return { urn: fullResponse.headers['x-restli-id'] };
} else {
return fullResponse.body;
}
}
export async function linkedInApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
body: any = {},
binary?: boolean,
_headers?: object,
): Promise<any> {
const authenticationMethod = this.getNodeParameter('authentication', 0);
const credentialType =
authenticationMethod === 'standard'
? 'linkedInOAuth2Api'
: 'linkedInCommunityManagementOAuth2Api';
const baseUrl = 'https://api.linkedin.com';
let options: IRequestOptions = {
headers: {
Accept: 'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'LinkedIn-Version': '202504',
},
method,
body,
url: binary ? endpoint : `${baseUrl}${endpoint.includes('v2') ? '' : '/rest'}${endpoint}`,
json: true,
};
options = Object.assign({}, options, {
resolveWithFullResponse: true,
});
// If uploading binary data
if (binary) {
delete options.json;
options.encoding = null;
if (Object.keys(_headers as object).length > 0) {
Object.assign(options.headers as object, _headers);
}
}
if (Object.keys(body as IDataObject).length === 0) {
delete options.body;
}
try {
return resolveHeaderData(
await this.helpers.requestOAuth2.call(this, credentialType, options, {
tokenType: 'Bearer',
}),
);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export function validateJSON(json: string | undefined): any {
let result;
try {
result = JSON.parse(json!);
} catch (exception) {
result = '';
}
return result;
}
@@ -0,0 +1,25 @@
{
"node": "n8n-nodes-base.linkedIn",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Marketing", "Communication"],
"resources": {
"credentialDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/credentials/linkedin/"
}
],
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.linkedin/"
}
],
"generic": [
{
"label": "Why business process automation with n8n can change your daily life",
"icon": "🧬",
"url": "https://n8n.io/blog/why-business-process-automation-with-n8n-can-change-your-daily-life/"
}
]
}
}
@@ -0,0 +1,310 @@
import type {
IDataObject,
IExecuteFunctions,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import { linkedInApiRequest } from './GenericFunctions';
import { postFields, postOperations } from './PostDescription';
export class LinkedIn implements INodeType {
description: INodeTypeDescription = {
displayName: 'LinkedIn',
name: 'linkedIn',
icon: 'file:linkedin.svg',
group: ['input'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume LinkedIn API',
defaults: {
name: 'LinkedIn',
},
builderHint: {
message: 'LinkedIn API does not support scraping profiles or leads.',
relatedNodes: [
{
nodeType: 'n8n-nodes-base.phantombuster',
relationHint: 'For LinkedIn lead scraping and data extraction',
},
],
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
credentials: [
{
name: 'linkedInOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: ['standard'],
},
},
},
{
name: 'linkedInCommunityManagementOAuth2Api',
required: true,
displayOptions: {
show: {
authentication: ['communityManagement'],
},
},
},
],
properties: [
{
displayName: 'Authentication',
name: 'authentication',
type: 'options',
options: [
{
name: 'Standard',
value: 'standard',
},
{
name: 'Community Management',
value: 'communityManagement',
},
],
default: 'standard',
},
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Post',
value: 'post',
},
],
default: 'post',
},
//POST
...postOperations,
...postFields,
],
};
methods = {
loadOptions: {
// Get Person URN which has to be used with other LinkedIn API Requests
// https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin
async getPersonUrn(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const authentication = this.getNodeParameter('authentication', 0);
let endpoint = '/v2/me';
if (authentication === 'standard') {
const { legacy } = await this.getCredentials('linkedInOAuth2Api');
if (!legacy) {
endpoint = '/v2/userinfo';
}
}
const person = await linkedInApiRequest.call(this, 'GET', endpoint, {});
const firstName = person.localizedFirstName ?? person.given_name;
const lastName = person.localizedLastName ?? person.family_name;
const name = `${firstName} ${lastName}`;
const returnData: INodePropertyOptions[] = [
{
name,
value: person.id ?? person.sub,
},
];
return returnData;
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
let body: any = {};
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'post') {
if (operation === 'create') {
let text = this.getNodeParameter('text', i) as string;
const shareMediaCategory = this.getNodeParameter('shareMediaCategory', i) as string;
const postAs = this.getNodeParameter('postAs', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i);
// LinkedIn uses "little text" https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/little-text-format?view=li-lms-2024-06
text = text.replace(/[\(*\)\[\]\{\}<>@|~_]/gm, (char) => '\\' + char);
let authorUrn = '';
let visibility = 'PUBLIC';
if (postAs === 'person') {
const personUrn = this.getNodeParameter('person', i) as string;
// Only if posting as a person can user decide if post visible by public or connections
visibility = (additionalFields.visibility as string) || 'PUBLIC';
authorUrn = `urn:li:person:${personUrn}`;
} else {
const organizationUrn = this.getNodeParameter('organization', i) as string;
authorUrn = `urn:li:organization:${organizationUrn}`;
}
let description = '';
let title = '';
let originalUrl = '';
body = {
author: authorUrn,
lifecycleState: 'PUBLISHED',
distribution: {
feedDistribution: 'MAIN_FEED',
thirdPartyDistributionChannels: [],
},
visibility,
};
if (shareMediaCategory === 'IMAGE') {
if (additionalFields.title) {
title = additionalFields.title as string;
}
// Send a REQUEST to prepare a register of a media image file
const registerRequest = {
initializeUploadRequest: {
owner: authorUrn,
},
};
const registerObject = await linkedInApiRequest.call(
this,
'POST',
'/images?action=initializeUpload',
registerRequest,
);
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
const { uploadUrl, image } = registerObject.value;
const headers = {};
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
await linkedInApiRequest.call(
this,
'POST',
uploadUrl as string,
buffer,
true,
headers,
);
const imageBody = {
content: {
media: {
title,
id: image,
},
},
commentary: text,
};
Object.assign(body, imageBody);
} else if (shareMediaCategory === 'ARTICLE') {
if (additionalFields.description) {
description = additionalFields.description as string;
}
if (additionalFields.title) {
title = additionalFields.title as string;
}
if (additionalFields.originalUrl) {
originalUrl = additionalFields.originalUrl as string;
}
const articleBody = {
content: {
article: {
title,
description,
source: originalUrl,
},
},
commentary: text,
};
if (additionalFields.thumbnailBinaryPropertyName) {
const registerRequest = {
initializeUploadRequest: {
owner: authorUrn,
},
};
const registerObject = await linkedInApiRequest.call(
this,
'POST',
'/images?action=initializeUpload',
registerRequest,
);
const binaryPropertyName = additionalFields.thumbnailBinaryPropertyName as string;
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
const { uploadUrl, image } = registerObject.value;
const headers = {};
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
await linkedInApiRequest.call(
this,
'POST',
uploadUrl as string,
buffer,
true,
headers,
);
Object.assign(articleBody.content.article, { thumbnail: image });
}
Object.assign(body, articleBody);
if (description === '') {
delete body.description;
}
if (title === '') {
delete body.title;
}
} else {
Object.assign(body, {
commentary: text,
});
}
const endpoint = '/posts';
responseData = await linkedInApiRequest.call(this, 'POST', endpoint, body);
}
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
}
return [returnData];
}
}
@@ -0,0 +1,223 @@
import type { INodeProperties } from 'n8n-workflow';
export const postOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['post'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new post',
action: 'Create a post',
},
],
default: 'create',
},
];
export const postFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* post:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Post As',
name: 'postAs',
type: 'options',
default: 'person',
description: 'If to post on behalf of a user or an organization',
options: [
{
name: 'Person',
value: 'person',
},
{
name: 'Organization',
value: 'organization',
},
],
},
{
displayName: 'Person Name or ID',
name: 'person',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getPersonUrn',
},
default: '',
required: true,
description:
'Person as which the post should be posted as. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
displayOptions: {
show: {
operation: ['create'],
postAs: ['person'],
resource: ['post'],
},
},
},
{
displayName: 'Organization URN',
name: 'organization',
type: 'string',
default: '',
placeholder: '1234567',
description: 'URN of Organization as which the post should be posted as',
displayOptions: {
show: {
operation: ['create'],
postAs: ['organization'],
resource: ['post'],
},
},
},
{
displayName: 'Text',
name: 'text',
type: 'string',
default: '',
description: 'The primary content of the post',
displayOptions: {
show: {
operation: ['create'],
resource: ['post'],
},
},
},
{
displayName: 'Media Category',
name: 'shareMediaCategory',
type: 'options',
default: 'NONE',
options: [
{
name: 'None',
value: 'NONE',
description: 'The post does not contain any media, and will only consist of text',
},
{
name: 'Article',
value: 'ARTICLE',
description: 'The post contains an article URL',
},
{
name: 'Image',
value: 'IMAGE',
description: 'The post contains an image',
},
],
displayOptions: {
show: {
operation: ['create'],
resource: ['post'],
},
},
},
{
displayName: 'Input Binary Field',
displayOptions: {
show: {
operation: ['create'],
resource: ['post'],
shareMediaCategory: ['IMAGE'],
},
},
name: 'binaryPropertyName',
type: 'string',
default: 'data',
hint: 'The name of the input binary field containing the file to be written',
required: true,
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
operation: ['create'],
resource: ['post'],
},
},
options: [
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'Provide a short description for your image or article',
displayOptions: {
show: {
'/shareMediaCategory': ['ARTICLE'],
},
},
},
{
displayName: 'Original URL',
name: 'originalUrl',
type: 'string',
default: '',
description: 'Provide the URL of the article you would like to share here',
displayOptions: {
show: {
'/shareMediaCategory': ['ARTICLE'],
},
},
},
{
displayName: 'Input Binary Field',
name: 'thumbnailBinaryPropertyName',
type: 'string',
default: 'data',
hint: 'The name of the input binary field containing the file for the article thumbnail',
displayOptions: {
show: {
'/shareMediaCategory': ['ARTICLE'],
},
},
},
{
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
description: 'Customize the title of your image or article',
displayOptions: {
show: {
'/shareMediaCategory': ['ARTICLE', 'IMAGE'],
},
},
},
{
displayName: 'Visibility',
name: 'visibility',
type: 'options',
default: 'PUBLIC',
description: 'Dictate if post will be seen by the public or only connections',
displayOptions: {
show: {
'/postAs': ['person'],
},
},
options: [
{
name: 'Connections',
value: 'CONNECTIONS',
},
{
name: 'Public',
value: 'PUBLIC',
},
],
},
],
},
];
@@ -0,0 +1,9 @@
{
"type": "object",
"properties": {
"urn": {
"type": "string"
}
},
"version": 1
}
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="#fff" fill-rule="evenodd" stroke="#000" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 67 66"><use xlink:href="#a" x="1" y="1"/><symbol id="a" overflow="visible"><g fill-rule="nonzero" stroke="none"><path fill="#0177b5" d="M59.26 0H4.724C2.12 0 0 2.066 0 4.61v54.788c0 2.53 2.12 4.6 4.724 4.6h54.54c2.61 0 4.736-2.07 4.736-4.6V4.61C64 2.066 61.874 0 59.26 0"/><path d="M9.49 23.992H19v30.54H9.49zm4.748-15.2c3.034 0 5.5 2.466 5.5 5.5a5.51 5.51 0 0 1-5.498 5.506 5.52 5.52 0 0 1-5.508-5.506 5.5 5.5 0 0 1 5.506-5.5m10.7 15.2h9.104v4.174h.126c1.268-2.4 4.364-4.932 9-4.932 9.612 0 11.386 6.326 11.386 14.548v16.752h-9.486V39.678c0-3.54-.064-8.1-4.932-8.1-4.94 0-5.7 3.86-5.7 7.84v15.108h-9.484v-30.54z"/></g></symbol></svg>

After

Width:  |  Height:  |  Size: 823 B