LinkedIn Skill
You have access to linkedin – a CLI tool for LinkedIn automation. Use it to fetch profiles, search people and companies, send messages, manage connections, create posts, react, comment, and more.
Each command sends a request to Linked API, which runs a real cloud browser to perform the action on LinkedIn. Operations are not instant – expect 30 seconds to several minutes depending on complexity.
If linkedin is not available, install it:
CODEBLOCK0
Authentication
If a command fails with exit code 2 (authentication error), ask the user to set up their account:
- 1. Go to app.linkedapi.io and sign up or log in
- Connect their LinkedIn account
- Copy the Linked API Token and Identification Token from the dashboard
Once the user provides the tokens, run:
CODEBLOCK1
Global Flags
Always use --json and -q for machine-readable output:
CODEBLOCK2
| Flag | Description |
|---|
| INLINECODE4 | Structured JSON output |
| INLINECODE5 / INLINECODE6 |
Suppress stderr progress messages |
|
--fields name,url,... | Select specific fields in output |
|
--no-color | Disable colors |
|
--account "Name" | Use a specific account for this command |
Output Format
Success:
CODEBLOCK3
Error:
CODEBLOCK4
Exit code 0 means the API call succeeded – always check the success field for the action outcome. Non-zero exit codes indicate infrastructure errors:
| Exit Code | Meaning |
|---|
| 0 | Success (check success field – action may have returned an error like "person not found") |
| 1 |
General/unexpected error |
| 2 | Missing or invalid tokens |
| 3 | Subscription/plan required |
| 4 | LinkedIn account issue |
| 5 | Invalid arguments |
| 6 | Rate limited |
| 7 | Network error |
| 8 | Workflow timeout (workflowId returned for recovery) |
Commands
Fetch a Person Profile
CODEBLOCK5
Optional flags to include additional data:
- -
--experience – work history - INLINECODE13 – education history
- INLINECODE14 – skills list
- INLINECODE15 – languages
- INLINECODE16 – recent posts (with
--posts-limit N, --posts-since TIMESTAMP) - INLINECODE19 – recent comments (with
--comments-limit N, --comments-since TIMESTAMP) - INLINECODE22 – recent reactions (with
--reactions-limit N, --reactions-since TIMESTAMP)
Only request additional data when needed – each flag increases execution time.
CODEBLOCK6
Search People
CODEBLOCK7
| Flag | Description |
|---|
| INLINECODE25 | Search keyword or phrase |
| INLINECODE26 |
Max results |
|
--first-name | Filter by first name |
|
--last-name | Filter by last name |
|
--position | Filter by job position |
|
--locations | Comma-separated locations |
|
--industries | Comma-separated industries |
|
--current-companies | Comma-separated current company names |
|
--previous-companies | Comma-separated previous company names |
|
--schools | Comma-separated school names |
CODEBLOCK8
Fetch a Company
CODEBLOCK9
Optional flags:
- -
--employees – include employees - INLINECODE36 – include decision makers
- INLINECODE37 – include company posts
Employee filters (require --employees):
| Flag | Description |
|---|
| INLINECODE39 | Max employees to retrieve |
| INLINECODE40 |
Filter by first name |
|
--employees-last-name | Filter by last name |
|
--employees-position | Filter by position |
|
--employees-locations | Comma-separated locations |
|
--employees-industries | Comma-separated industries |
|
--employees-schools | Comma-separated school names |
| Flag | Description |
|---|
| INLINECODE46 | Max decision makers to retrieve (requires --dms) |
| INLINECODE48 |
Max posts to retrieve (requires
--posts) |
|
--posts-since | Posts since ISO timestamp (requires
--posts) |
CODEBLOCK10
Search Companies
CODEBLOCK11
| Flag | Description |
|---|
| INLINECODE52 | Search keyword |
| INLINECODE53 |
Max results |
|
--sizes | Comma-separated sizes:
1-10,
11-50,
51-200,
201-500,
501-1000,
1001-5000,
5001-10000,
10001+ |
|
--locations | Comma-separated locations |
|
--industries | Comma-separated industries |
CODEBLOCK12
Send a Message
CODEBLOCK13
Text up to 1900 characters. Wrap the message in single quotes to avoid shell interpretation issues.
CODEBLOCK14
Get Conversation
CODEBLOCK15
The first call for a conversation triggers a background sync and may take longer. Subsequent calls are faster.
CODEBLOCK16
Connection Management
Check connection status
CODEBLOCK17
Send connection request
CODEBLOCK18
List connections
CODEBLOCK19
| Flag | Description |
|---|
| INLINECODE65 | Max connections to return |
| INLINECODE66 |
Only connections made since ISO timestamp (only works when no filter flags are used) |
|
--first-name | Filter by first name |
|
--last-name | Filter by last name |
|
--position | Filter by job position |
|
--locations | Comma-separated locations |
|
--industries | Comma-separated industries |
|
--current-companies | Comma-separated current company names |
|
--previous-companies | Comma-separated previous company names |
|
--schools | Comma-separated school names |
CODEBLOCK20
List pending outgoing requests
CODEBLOCK21
Withdraw a pending request
CODEBLOCK22
By default, withdrawing also unfollows the person. Use --no-unfollow to keep following.
Remove a connection
CODEBLOCK23
Posts
Fetch a post
CODEBLOCK24
| Flag | Description |
|---|
| INLINECODE76 | Include comments |
| INLINECODE77 |
Include reactions |
|
--comments-limit | Max comments to retrieve (requires
--comments) |
|
--comments-sort | Sort order:
mostRelevant or
mostRecent (requires
--comments) |
|
--comments-replies | Include replies to comments (requires
--comments) |
|
--reactions-limit | Max reactions to retrieve (requires
--reactions) |
CODEBLOCK25
Create a post
CODEBLOCK26
| Flag | Description |
|---|
| INLINECODE88 | Post on behalf of a company page (requires admin access) |
| INLINECODE89 |
Attachment as
url:type or
url:type:name. Types:
image,
video,
document. Can be specified multiple times. |
Attachment limits: up to 9 images, or 1 video, or 1 document. Cannot mix types.
CODEBLOCK27
React to a post
CODEBLOCK28
Reaction types: like, love, support, celebrate, insightful, funny.
CODEBLOCK29
Comment on a post
CODEBLOCK30
Text up to 1000 characters.
CODEBLOCK31
Statistics
CODEBLOCK32
Sales Navigator
Requires a LinkedIn Sales Navigator subscription. Uses hashed URLs for person/company lookups.
Fetch person
CODEBLOCK33
Search people
CODEBLOCK34
| Flag | Description |
|---|
| INLINECODE101 | Search keyword or phrase |
| INLINECODE102 |
Max results |
|
--first-name | Filter by first name |
|
--last-name | Filter by last name |
|
--position | Filter by job position |
|
--locations | Comma-separated locations |
|
--industries | Comma-separated industries |
|
--current-companies | Comma-separated current company names |
|
--previous-companies | Comma-separated previous company names |
|
--schools | Comma-separated school names |
|
--years-of-experience | Comma-separated ranges:
lessThanOne,
oneToTwo,
threeToFive,
sixToTen,
moreThanTen |
CODEBLOCK35
Fetch company
CODEBLOCK36
Optional flags:
- -
--employees – include employees - INLINECODE118 – include decision makers
Employee filters (require --employees):
| Flag | Description |
|---|
| INLINECODE120 | Max employees to retrieve |
| INLINECODE121 |
Filter by first name |
|
--employees-last-name | Filter by last name |
|
--employees-positions | Comma-separated positions |
|
--employees-locations | Comma-separated locations |
|
--employees-industries | Comma-separated industries |
|
--employees-schools | Comma-separated school names |
|
--employees-years-of-experience | Comma-separated experience ranges |
|
--dms-limit | Max decision makers to retrieve (requires
--dms) |
CODEBLOCK37
Search companies
CODEBLOCK38
| Flag | Description |
|---|
| INLINECODE130 | Search keyword |
| INLINECODE131 |
Max results |
|
--sizes | Comma-separated sizes:
1-10,
11-50,
51-200,
201-500,
501-1000,
1001-5000,
5001-10000,
10001+ |
|
--locations | Comma-separated locations |
|
--industries | Comma-separated industries |
|
--revenue-min | Min annual revenue in M USD:
0,
0.5,
1,
2.5,
5,
10,
20,
50,
100,
500,
1000 |
|
--revenue-max | Max annual revenue in M USD:
0.5,
1,
2.5,
5,
10,
20,
50,
100,
500,
1000,
1000+ |
CODEBLOCK39
Send InMail
CODEBLOCK40
Text up to 1900 characters. Subject up to 80 characters.
CODEBLOCK41
Get Sales Navigator conversation
CODEBLOCK42
Custom Workflows
Execute a custom workflow definition from a file, stdin, or inline:
CODEBLOCK43
Check workflow status or wait for completion:
CODEBLOCK44
See Building Workflows for the workflow JSON schema.
Account Management
CODEBLOCK45
Important Behavior
- - Sequential execution. All operations for an account run one at a time. Multiple requests queue up.
- Not instant. A real browser navigates LinkedIn – expect 30 seconds to several minutes per operation.
- Timestamps in UTC. All dates and times are in UTC.
- Single quotes for text arguments. Use single quotes around message text, post text, and comments to avoid shell interpretation issues with special characters.
- Action limits. Per-account limits are configurable on the platform. A
limitExceeded error means the limit was reached. - URL normalization. All LinkedIn URLs in responses are normalized to
https://www.linkedin.com/... format without trailing slashes. - Null fields. Fields that are unavailable are returned as
null or [], not omitted.
LinkedIn 技能
你可以使用 linkedin —— 一个用于 LinkedIn 自动化的 CLI 工具。它可以用来获取个人资料、搜索人员和公司、发送消息、管理连接、创建帖子、点赞、评论等。
每个命令都会向 Linked API 发送请求,该 API 会运行一个真实的云浏览器来在 LinkedIn 上执行操作。操作不是即时完成的——根据复杂程度,预计需要 30 秒到几分钟。
如果 linkedin 不可用,请安装它:
bash
npm install -g @linkedapi/linkedin-cli
身份验证
如果命令以退出码 2(身份验证错误)失败,请让用户设置他们的账户:
- 1. 前往 app.linkedapi.io 注册或登录
- 连接他们的 LinkedIn 账户
- 从控制面板复制 Linked API Token 和 Identification Token
一旦用户提供了令牌,运行:
bash
linkedin setup --linked-api-token=TOKEN --identification-token=TOKEN
全局标志
始终使用 --json 和 -q 以获得机器可读的输出:
bash
linkedin --json -q
| 标志 | 描述 |
|---|
| --json | 结构化 JSON 输出 |
| --quiet / -q |
抑制 stderr 进度消息 |
| --fields name,url,... | 在输出中选择特定字段 |
| --no-color | 禁用颜色 |
| --account Name | 为此命令使用特定账户 |
输出格式
成功:
json
{success: true, data: {name: John Doe, headline: Engineer}}
错误:
json
{success: false, error: {type: personNotFound, message: Person not found}}
退出码 0 表示 API 调用成功——始终检查 success 字段以了解操作结果。非零退出码表示基础设施错误:
| 退出码 | 含义 |
|---|
| 0 | 成功(检查 success 字段——操作可能返回了类似person not found的错误) |
| 1 |
一般/意外错误 |
| 2 | 缺少或无效的令牌 |
| 3 | 需要订阅/套餐 |
| 4 | LinkedIn 账户问题 |
| 5 | 无效参数 |
| 6 | 速率限制 |
| 7 | 网络错误 |
| 8 | 工作流超时(返回 workflowId 用于恢复) |
命令
获取个人资料
bash
linkedin person fetch [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)
仅在需要时请求额外数据——每个标志都会增加执行时间。
bash
基本资料
linkedin person fetch https://www.linkedin.com/in/username --json -q
包含工作经历和教育经历
linkedin person fetch https://www.linkedin.com/in/username --experience --education --json -q
包含最近 5 条帖子
linkedin person fetch https://www.linkedin.com/in/username --posts --posts-limit 5 --json -q
搜索人员
bash
linkedin person search [flags] --json -q
| 标志 | 描述 |
|---|
| --term | 搜索关键词或短语 |
| --limit |
最大结果数 |
| --first-name | 按名字筛选 |
| --last-name | 按姓氏筛选 |
| --position | 按职位筛选 |
| --locations | 逗号分隔的地点 |
| --industries | 逗号分隔的行业 |
| --current-companies | 逗号分隔的当前公司名称 |
| --previous-companies | 逗号分隔的前公司名称 |
| --schools | 逗号分隔的学校名称 |
bash
linkedin person search --term product manager --locations San Francisco --json -q
linkedin person search --current-companies Google --position Engineer --limit 20 --json -q
获取公司信息
bash
linkedin company fetch [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) |
bash
基本公司信息
linkedin company fetch https://www.linkedin.com/company/name --json -q
包含按职位筛选的员工
linkedin company fetch https://www.linkedin.com/company/name --employees --employees-position Engineer --json -q
包含决策者和帖子
linkedin company fetch https://www.linkedin.com/company/name --dms --posts --posts-limit 10 --json -q
搜索公司
bash
linkedin company search [flags] --json -q
最大结果数 |
| --sizes | 逗号分隔的规模:1-10,11-50,51-200,201-500,501-1000,1001-5000,5001-10000,10001+ |
| --locations | 逗号分隔的地点 |
| --industries | 逗号分隔的行业 |
bash
linkedin company search --term fintech --sizes 11-50,51-200 --json -q
发送消息
bash
linkedin message send --json -q
文本最多 1900 个字符。将消息用单引号括起来以避免 shell 解释问题。
bash
linkedin message send https://www.linkedin.com/in/username Hey, loved your latest post! --json -q
获取对话
bash
linkedin message get [--since TIMESTAMP] --json -q
首次调用对话会触发后台同步,可能需要更长时间。后续调用会更快。
bash
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
连接管理
检查连接状态
bash
linkedin connection status --json -q
发送连接请求
bash
linkedin connection send [--note text] [--email user@example.com] --json -q
列出连接
bash
linkedin connection list [flags] --json -q
| 标志 | 描述 |
|---|
| --limit | 最大返回连接数 |
| --since |
仅返回自 ISO 时间戳以来的连接(仅当未使用筛选标志时有效) |
| --first-name | 按名字筛选 |
| --last-name | 按姓氏筛选 |
| --position | 按职位筛选 |
| --locations | 逗号分隔的地点 |
| --industries | 逗号分隔的行业 |
| --current-companies | 逗号分隔的当前公司