关于 linkedin
linkedin 是基于 Linked API 的 LinkedIn 自动化命令行工具,供需要查询资料、管理关系和发布互动内容的用户使用。它通过云端浏览器执行操作,并提供结构化 JSON 输出。
主要功能
- 01查询个人与公司资料
- 02搜索人员和公司
- 03收发消息及管理联系人
- 04创建帖子并互动
- 05提供 JSON 输出与筛选选项
适用场景
- 01按职位和地点筛选潜在联系人
- 02查看公司员工、决策者及帖子
- 03获取个人资料和近期动态
- 04管理 LinkedIn 消息与连接请求
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ bobmatnyc/ claude-mpm-skills --skill linkedin安装后在 Claude Code 中输入/linkedin确认已加载。
附带文件metadata.json
详细介绍
LinkedIn - Linked API 自动化 CLI
概述
linkedin 是一款基于 Linked API 构建的 LinkedIn 自动化 CLI 工具。可用于获取个人资料、搜索用户和公司、发送消息、管理人脉、创建帖子、进行互动、发表评论,以及运行 Sales Navigator 和自定义工作流。
每条命令都会向 Linked API 发送请求,由它运行真实的云端浏览器来执行 LinkedIn 操作。操作并非即时完成——具体耗时取决于复杂程度,可能从 30 秒到几分钟不等。
如果无法使用 linkedin,请安装 CLI:
npm install -g @linkedapi/linkedin-cli
安全与合规
运行任何命令前,请先阅读以下内容。
- LinkedIn《用户协议》风险。 自动发送人脉邀请、消息和帖子,以及抓取数据,都可能违反 LinkedIn《用户协议》,并导致账号受限或被封禁。账号所有者有责任遵守 LinkedIn 的条款和适用法律。在大规模执行写入操作前,请确认用户已接受此风险。
- 确认写入和主动联系操作。 发送消息、人脉邀请、InMail、帖子、互动或评论前,必须获得用户明确批准。请先展示确切的目标和内容。
- 仅使用凭据。 使用从控制面板获取的 Linked API token 和识别 token。切勿索要 LinkedIn 密码、2FA 验证码、Cookie、会话导出文件、恢复码或浏览器配置文件数据。
- 遵守操作限制。 平台可配置每个账号的操作限制。出现
limitExceeded错误意味着已达到限制——请停止操作并报告,不要重试。
身份验证
CLI 从环境变量读取凭据。请导出凭据,以免机密信息留在 Shell 历史记录和进程列表中。切勿将 token 作为 CLI 参数传入。
如果命令以退出代码 2 失败(身份验证错误),请指导用户完成设置:
- 前往 app.linkedapi.io 注册或登录。
- 连接 LinkedIn 账号。
- 从控制面板复制 Linked API Token 和 Identification Token。
导出 token 并运行设置:
export LINKEDAPI_TOKEN="your-linked-api-token"
export LINKEDAPI_IDENTIFICATION_TOKEN="your-identification-token"
linkedin setup
如果 token 已泄露,请将其视为已被盗用,并在 Linked API 控制面板中轮换。请勿将 token 放入源文件、已提交的示例、问题文本、聊天记录、屏幕截图或日志中。
全局标志
机器可读输出始终使用 --json 和 -q:
linkedin <command> --json -q
也可以在环境中设置一次 LINKEDAPI_CLIENT=skill:linkedin,让 Linked API 将用量归因于此技能。无需在每条命令中重复设置。
| 标志 | 说明 |
|---|---|
--json | 结构化 JSON 输出 |
--quiet / -q | 禁止输出 stderr 进度消息 |
--fields name,url,... | 选择输出中的特定字段 |
--no-color | 禁用颜色 |
--account "Name" | 此命令使用指定账号 |
输出格式
成功:
{"success": true, "data": {"name": "John Doe", "headline": "Engineer"}}
错误:
{"success": false, "error": {"type": "personNotFound", "message": "Person not found"}}
退出代码 0 表示 API 调用成功——请始终检查 success 字段,以确认操作结果。非零退出代码表示基础设施错误:
| 退出代码 | 含义 |
|---|---|
| 0 | 成功(请检查 success 字段——操作可能返回了类似“未找到用户”的错误) |
| 1 | 一般/意外错误 |
| 2 | 缺少或无效的 token |
| 3 | 需要订阅/套餐 |
| 4 | LinkedIn 账号问题 |
| 5 | 参数无效 |
| 6 | 触发速率限制 |
| 7 | 网络错误 |
| 8 | 工作流超时(已返回 workflowId,可用于恢复) |
命令
获取个人资料
linkedin person fetch <url> [flags] --json -q
可选标志,用于包含其他数据:
--experience- 工作经历--education- 教育经历--skills- 技能列表--languages- 语言--posts- 最新帖子(使用--posts-limit N、--posts-since TIMESTAMP)--comments- 最新评论(使用--comments-limit N、--comments-since TIMESTAMP)--reactions- 最新动态(使用--reactions-limit N、--reactions-since TIMESTAMP)
仅在需要时请求其他数据——每个标志都会增加执行时间。
# Basic profile
linkedin person fetch https://www.linkedin.com/in/username --json -q
# With experience and education
linkedin person fetch https://www.linkedin.com/in/username --experience --education --json -q
# With last 5 posts
linkedin person fetch https://www.linkedin.com/in/username --posts --posts-limit 5 --json -q
搜索人员
linkedin person search [flags] --json -q
| 标志 | 说明 |
|---|---|
--term | 搜索关键词或短语 |
--limit | 结果数量上限 |
--first-name | 按名字筛选 |
--last-name | 按姓氏筛选 |
--position | 按职位筛选 |
--locations | 以逗号分隔的地点 |
--industries | 以逗号分隔的行业 |
--current-companies | 以逗号分隔的当前公司名称 |
--previous-companies | 以逗号分隔的过往公司名称 |
--schools | 以逗号分隔的学校名称 |
linkedin person search --term "product manager" --locations "San Francisco" --json -q
linkedin person search --current-companies "Google" --position "Engineer" --limit 20 --json -q
获取公司信息
linkedin company fetch <url> [flags] --json -q
可选标志:
--employees- 包含员工--dms- 包含决策者--posts- 包含公司帖子
员工筛选条件(需要 --employees):
| 标志 | 说明 |
|---|---|
--employees-limit | 要获取的员工数量上限 |
--employees-first-name | 按名字筛选 |
--employees-last-name | 按姓氏筛选 |
--employees-position | 按职位筛选 |
--employees-locations | 以逗号分隔的地点 |
--employees-industries | 以逗号分隔的行业 |
--employees-schools | 以逗号分隔的学校名称 |
| 标志 | 说明 |
|---|---|
--dms-limit | 要获取的决策者数量上限(需要 --dms) |
--posts-limit | 要获取的帖子数量上限(需要 --posts) |
--posts-since | 获取自 ISO 时间戳以来的帖子(需要 --posts) |
# Basic company info
linkedin company fetch https://www.linkedin.com/company/name --json -q
# With employees filtered by position
linkedin company fetch https://www.linkedin.com/company/name --employees --employees-position "Engineer" --json -q
# With decision makers and posts
linkedin company fetch https://www.linkedin.com/company/name --dms --posts --posts-limit 10 --json -q
搜索公司
linkedin company search [flags] --json -q
| 标志 | 说明 |
|---|---|
--term | 搜索关键词 |
--limit | 结果数量上限 |
--sizes | 以逗号分隔的规模:1-10、11-50、51-200、201-500、501-1000、1001-5000、5001-10000、10001+ |
--locations | 以逗号分隔的地点 |
--industries | 以逗号分隔的行业 |
linkedin company search --term "fintech" --sizes "11-50,51-200" --json -q
发送消息
linkedin message send <person-url> '<text>' --json -q
文本最多 1900 个字符。请用单引号括起消息,以避免 Shell 解释问题。
linkedin message send https://www.linkedin.com/in/username 'Hey, loved your latest post!' --json -q
获取对话
linkedin message get <person-url> [--since TIMESTAMP] --json -q
首次调用某个对话时会触发后台同步,因此耗时较长;后续调用会更快。
linkedin message get https://www.linkedin.com/in/username --json -q
linkedin message get https://www.linkedin.com/in/username --since 2024-01-15T10:30:00Z --json -q
连接管理
检查连接状态
linkedin connection status <url> --json -q
发送连接请求
linkedin connection send <url> [--note 'text'] [--email [email protected]] --json -q
列出连接
linkedin connection list [flags] --json -q
| 标志 | 说明 |
|---|---|
--limit | 返回的连接数量上限 |
--since | 仅列出自 ISO 时间戳以来建立的连接(仅在未使用筛选标志时有效) |
--first-name | 按名字筛选 |
--last-name | 按姓氏筛选 |
--position | 按职位筛选 |
--locations | 以逗号分隔的地点 |
--industries | 以逗号分隔的行业 |
--current-companies | 以逗号分隔的当前公司名称 |
--previous-companies | 以逗号分隔的过往公司名称 |
--schools | 以逗号分隔的学校名称 |
linkedin connection list --limit 50 --json -q
linkedin connection list --current-companies "Google" --position "Engineer" --json -q
linkedin connection list --since 2024-01-01T00:00:00Z --json -q
列出待处理的发出请求
linkedin connection pending --json -q
撤回待处理的请求
linkedin connection withdraw <url> [--no-unfollow] --json -q
默认情况下,撤回请求也会取消关注该人员。使用 --no-unfollow 可继续关注。
移除连接
linkedin connection remove <url> --json -q
帖子
获取帖子
linkedin post fetch <url> [flags] --json -q
| 标志 | 说明 |
|---|---|
--comments | 包含评论 |
--reactions | 包含反应 |
--comments-limit | 要检索的评论数量上限(需要 --comments) |
--comments-sort | 排序方式:mostRelevant 或 mostRecent(需要 --comments) |
--comments-replies | 包含评论的回复(需要 --comments) |
--reactions-limit | 要检索的反应数量上限(需要 --reactions) |
linkedin post fetch https://www.linkedin.com/posts/username_activity-123 --json -q
# With comments sorted by most recent, including replies
linkedin post fetch https://www.linkedin.com/posts/username_activity-123 \
--comments --comments-sort mostRecent --comments-replies --json -q
创建帖子
linkedin post create '<text>' [flags] --json -q
| 标志 | 说明 |
|---|---|
--company-url | 代表公司主页发布帖子(需要管理员权限) |
--attachments | 附件格式为 url:type 或 url:type:name。类型:image、video、document。可多次指定。 |
附件限制:最多 9 张图片、1 个视频或 1 份文档。不能混合类型。
linkedin post create 'Excited to share our latest update!' --json -q
# With a document
linkedin post create 'Our Q4 report' \
--attachments "https://example.com/report.pdf:document:Q4 Report" --json -q
# Post as a company
linkedin post create 'Company announcement' \
--company-url https://www.linkedin.com/company/name --json -q
对帖子作出反应
linkedin post react <url> --type <reaction> [--company-url <url>] --json -q
反应类型:like、love、support、celebrate、insightful、funny。
linkedin post react https://www.linkedin.com/posts/username_activity-123 --type like --json -q
# React on behalf of a company
linkedin post react https://www.linkedin.com/posts/username_activity-123 --type celebrate \
--company-url https://www.linkedin.com/company/name --json -q
评论帖子
linkedin post comment <url> '<text>' [--company-url <url>] --json -q
文本最多 1000 个字符。
linkedin post comment https://www.linkedin.com/posts/username_activity-123 'Great insights!' --json -q
# Comment on behalf of a company
linkedin post comment https://www.linkedin.com/posts/username_activity-123 'Well said!' \
--company-url https://www.linkedin.com/company/name --json -q
统计数据
# Social Selling Index
linkedin stats ssi --json -q
# Performance analytics (profile views, post impressions, search appearances)
linkedin stats performance --json -q
# API usage for a date range
linkedin stats usage --start 2024-01-01T00:00:00Z --end 2024-01-31T00:00:00Z --json -q
Sales Navigator
需要 LinkedIn Sales Navigator 订阅。按人物或公司查找时使用经过哈希处理的 URL。
获取人物信息
linkedin navigator person fetch <hashed-url> --json -q
搜索人物
linkedin navigator person search [flags] --json -q
| 标志 | 说明 |
|---|---|
--term | 搜索关键词或短语 |
--limit | 结果数量上限 |
--first-name | 按名字筛选 |
--last-name | 按姓氏筛选 |
--position | 按职位筛选 |
--locations | 以逗号分隔的地点 |
--industries | 以逗号分隔的行业 |
--current-companies | 以逗号分隔的当前公司名称 |
--previous-companies | 以逗号分隔的曾任职公司名称 |
--schools | 以逗号分隔的学校名称 |
--years-of-experience | 以逗号分隔的范围:lessThanOne、oneToTwo、threeToFive、sixToTen、moreThanTen |
linkedin navigator person search --term "VP Marketing" --locations "United States" --json -q
linkedin navigator person search --years-of-experience "moreThanTen" --position "CEO" --json -q
获取公司信息
linkedin navigator company fetch <hashed-url> [flags] --json -q
可选标志:
--employees- 包含员工--dms- 包含决策者
员工筛选条件(需要 --employees):
| 标志 | 说明 |
|---|---|
--employees-limit | 要检索的员工数量上限 |
--employees-first-name | 按名字筛选 |
--employees-last-name | 按姓氏筛选 |
--employees-positions | 以逗号分隔的职位 |
--employees-locations | 以逗号分隔的地点 |
--employees-industries | 以逗号分隔的行业 |
--employees-schools | 以逗号分隔的学校名称 |
--employees-years-of-experience | 以逗号分隔的经验范围 |
--dms-limit | 要检索的决策者数量上限(需要 --dms) |
linkedin navigator company fetch https://www.linkedin.com/sales/company/97ural --employees --dms --json -q
linkedin navigator company fetch https://www.linkedin.com/sales/company/97ural \
--employees --employees-positions "Engineer,Designer" --employees-locations "Europe" --json -q
搜索公司
linkedin navigator company search [flags] --json -q
| 标志 | 说明 |
|---|---|
--term | 搜索关键词 |
--limit | 结果数量上限 |
--sizes | 以逗号分隔的规模:1-10、11-50、51-200、201-500、501-1000、1001-5000、5001-10000、10001+ |
--locations | 以逗号分隔的地点 |
--industries | 以逗号分隔的行业 |
--revenue-min | 年收入下限,单位为百万美元:0、0.5、1、2.5、5、10、20、50、100、500、1000 |
--revenue-max | 年收入上限,单位为百万美元:0.5、1、2.5、5、10、20、50、100、500、1000、1000+ |
linkedin navigator company search --term "fintech" --sizes "11-50,51-200" --json -q
linkedin navigator company search --revenue-min 10 --revenue-max 100 --locations "United States" --json -q
发送 InMail
linkedin navigator message send <person-url> '<text>' --subject '<subject>' --json -q
文本最多 1900 个字符。主题最多 80 个字符。
linkedin navigator message send https://www.linkedin.com/in/username \
'Would love to chat about API integrations' --subject 'Partnership Opportunity' --json -q
获取 Sales Navigator 对话
linkedin navigator message get <person-url> [--since TIMESTAMP] --json -q
自定义工作流
从文件、标准输入或内联定义执行自定义工作流:
# From file
linkedin workflow run --file workflow.json --json -q
# From stdin
cat workflow.json | linkedin workflow run --json -q
# Inline
echo '{"actions":[...]}' | linkedin workflow run --json -q
查看工作流状态或等待其完成:
linkedin workflow status <id> --json -q
linkedin workflow status <id> --wait --json -q
工作流 JSON 架构请参阅 构建工作流。
账户管理
linkedin account list # List accounts (* = active)
linkedin account switch "Name" # Switch active account
linkedin account rename "Name" --name "New Name" # Rename account
linkedin reset # Remove active account
linkedin reset --all # Remove all accounts
重要行为
- 顺序执行。 同一账户的所有操作都将逐一执行。多个请求会排队等待。
- 并非即时完成。 操作会通过真实浏览器访问 LinkedIn,请预留 30 秒到几分钟。
- 时间戳使用 UTC。 所有日期和时间均为 UTC。
- 文本参数使用单引号。 将消息文本、帖子文本和评论用单引号括起来,避免特殊字符导致 shell 解析问题。
- 操作限制。 可在平台上配置每个账户的限制。出现
limitExceeded错误表示已达到限制。 - URL 规范化。 响应中的所有 LinkedIn URL 都会规范化为
https://www.linkedin.com/...格式,且不带末尾斜杠。 - 空值字段。 无法获取的字段会返回
null或[],而不会省略。
反模式
- 不要将令牌作为 CLI 参数传递(
--linked-api-token=...)。请改为将其导出为环境变量,避免令牌出现在 shell 历史记录和进程列表中。 - 不要索取或接受 LinkedIn 密码、2FA 验证码、Cookie 或会话数据。只能使用由控制面板签发的令牌。
- 未经确认用户接受 LinkedIn 用户协议相关风险,不要进行批量触达或抓取。
- 遇到
limitExceeded或速率限制错误后,不要自动重试写入操作。请停止操作并报告错误。