@linkedapi/linkedin-cli 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +258 -0
- package/bin/dev.js +8 -0
- package/bin/run.js +5 -0
- package/oclif.manifest.json +4 -0
- package/package.json +114 -0
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# linkedin-cli
|
|
2
|
+
|
|
3
|
+
CLI for AI agents to automate LinkedIn via [Linked API](https://linkedapi.io).
|
|
4
|
+
|
|
5
|
+
Give your AI agent full LinkedIn capabilities: send messages, fetch profiles, search people and companies, manage connections, create posts, react, comment – all through simple CLI commands with structured JSON output. Built for Claude Code, Cursor, Codex, and any AI agent that can execute shell commands.
|
|
6
|
+
|
|
7
|
+
Under the hood, [Linked API](https://linkedapi.io) runs a dedicated cloud browser instance for each connected LinkedIn account. When your agent runs a command, the CLI sends the request to Linked API's infrastructure, where an isolated browser with a residential IP performs the action on LinkedIn – simulating human-like mouse movements, keyboard input, and natural browsing patterns. No local browsers, no proxies, no Selenium, no infrastructure to manage.
|
|
8
|
+
|
|
9
|
+
Your LinkedIn credentials are used only once during the initial account connection on the [platform](https://app.linkedapi.io) and are never stored. All subsequent interaction happens exclusively through private API tokens. Each account is fully isolated, and configurable action limits prevent LinkedIn policy violations. [Learn more about safety](https://linkedapi.io/safety).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g linkedin-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
linkedin setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The CLI will ask for your **Linked API Token** and **Identification Token**. Get them at [app.linkedapi.io](https://app.linkedapi.io).
|
|
24
|
+
|
|
25
|
+
For non-interactive environments (CI, scripts):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
linkedin setup --linked-api-token=xxx --identification-token=yyy
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Multiple accounts
|
|
32
|
+
|
|
33
|
+
Run `linkedin setup` again with different tokens to add more accounts. The last added account becomes active.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# List all accounts (* marks active)
|
|
37
|
+
linkedin account list
|
|
38
|
+
|
|
39
|
+
# Switch active account
|
|
40
|
+
linkedin account switch "John Doe"
|
|
41
|
+
|
|
42
|
+
# Use a specific account for one command
|
|
43
|
+
linkedin person fetch https://www.linkedin.com/in/... --account "John Doe"
|
|
44
|
+
|
|
45
|
+
# Remove active account (auto-switches to next)
|
|
46
|
+
linkedin reset
|
|
47
|
+
|
|
48
|
+
# Remove all accounts
|
|
49
|
+
linkedin reset --all
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### People
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Fetch a person profile
|
|
58
|
+
linkedin person fetch https://www.linkedin.com/in/john-doe
|
|
59
|
+
|
|
60
|
+
# Fetch with experience and posts
|
|
61
|
+
linkedin person fetch https://www.linkedin.com/in/john-doe --experience --posts --json
|
|
62
|
+
|
|
63
|
+
# Search for people
|
|
64
|
+
linkedin person search --term "software engineer" --locations "San Francisco" --json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Companies
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Fetch a company
|
|
71
|
+
linkedin company fetch https://www.linkedin.com/company/microsoft --json
|
|
72
|
+
|
|
73
|
+
# Fetch with employees and decision makers
|
|
74
|
+
linkedin company fetch https://www.linkedin.com/company/google --employees --dms
|
|
75
|
+
|
|
76
|
+
# Search companies
|
|
77
|
+
linkedin company search --term "fintech" --sizes "11-50,51-200" --json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Messages
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Send a message
|
|
84
|
+
linkedin message send https://www.linkedin.com/in/john-doe "Hello John!"
|
|
85
|
+
|
|
86
|
+
# Get conversation
|
|
87
|
+
linkedin message get https://www.linkedin.com/in/john-doe --json
|
|
88
|
+
linkedin message get https://www.linkedin.com/in/john-doe --since 2024-01-15T10:30:00Z
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Connections
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Check connection status
|
|
95
|
+
linkedin connection status https://www.linkedin.com/in/john-doe
|
|
96
|
+
|
|
97
|
+
# Send connection request
|
|
98
|
+
linkedin connection send https://www.linkedin.com/in/john-doe --note "Love to connect!"
|
|
99
|
+
|
|
100
|
+
# List connections
|
|
101
|
+
linkedin connection list --limit 50 --json
|
|
102
|
+
|
|
103
|
+
# Pending requests
|
|
104
|
+
linkedin connection pending --json
|
|
105
|
+
|
|
106
|
+
# Withdraw request
|
|
107
|
+
linkedin connection withdraw https://www.linkedin.com/in/john-doe
|
|
108
|
+
|
|
109
|
+
# Remove connection
|
|
110
|
+
linkedin connection remove https://www.linkedin.com/in/john-doe
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Posts
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Fetch a post
|
|
117
|
+
linkedin post fetch https://www.linkedin.com/posts/john-doe_activity-123 --comments --reactions
|
|
118
|
+
|
|
119
|
+
# Create a post
|
|
120
|
+
linkedin post create "Excited to share our latest update!"
|
|
121
|
+
|
|
122
|
+
# React to a post
|
|
123
|
+
linkedin post react https://www.linkedin.com/posts/john-doe_activity-123 --type like
|
|
124
|
+
|
|
125
|
+
# Comment on a post
|
|
126
|
+
linkedin post comment https://www.linkedin.com/posts/john-doe_activity-123 "Great insights!"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Statistics
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Social Selling Index
|
|
133
|
+
linkedin stats ssi --json
|
|
134
|
+
|
|
135
|
+
# Performance analytics
|
|
136
|
+
linkedin stats performance --json
|
|
137
|
+
|
|
138
|
+
# API usage
|
|
139
|
+
linkedin stats usage --start 2024-01-01T00:00:00Z --end 2024-01-31T00:00:00Z --json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Sales Navigator
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Person
|
|
146
|
+
linkedin navigator person fetch https://www.linkedin.com/in/ACwAAA...
|
|
147
|
+
linkedin navigator person search --term "VP Marketing" --locations "United States"
|
|
148
|
+
|
|
149
|
+
# Company
|
|
150
|
+
linkedin navigator company fetch https://www.linkedin.com/sales/company/1035 --employees
|
|
151
|
+
linkedin navigator company search --term "fintech" --revenue-min 1 --revenue-max 50
|
|
152
|
+
|
|
153
|
+
# Messages
|
|
154
|
+
linkedin navigator message send https://www.linkedin.com/in/john-doe "Hello!" --subject "Partnership"
|
|
155
|
+
linkedin navigator message get https://www.linkedin.com/in/john-doe
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Custom Workflows
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Run from file
|
|
162
|
+
linkedin workflow run --file workflow.json
|
|
163
|
+
|
|
164
|
+
# Pipe from stdin
|
|
165
|
+
cat workflow.json | linkedin workflow run
|
|
166
|
+
|
|
167
|
+
# Check status / wait for completion
|
|
168
|
+
linkedin workflow status abc123
|
|
169
|
+
linkedin workflow status abc123 --wait --json
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Global Flags
|
|
173
|
+
|
|
174
|
+
Every command supports:
|
|
175
|
+
|
|
176
|
+
| Flag | Description |
|
|
177
|
+
|------|-------------|
|
|
178
|
+
| `--json` | Structured JSON output to stdout |
|
|
179
|
+
| `--fields name,url,...` | Select specific fields in output |
|
|
180
|
+
| `--quiet` / `-q` | Suppress stderr progress |
|
|
181
|
+
| `--no-color` | Disable colors |
|
|
182
|
+
| `--account "Name"` | Use a specific account (when multiple are configured) |
|
|
183
|
+
|
|
184
|
+
## Output Format
|
|
185
|
+
|
|
186
|
+
### JSON mode (`--json` or non-TTY stdout)
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{"success": true, "data": {"name": "John Doe", "headline": "Engineer"}}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```json
|
|
193
|
+
{"success": false, "error": {"type": "personNotFound", "message": "Person not found"}}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Human mode (TTY stdout)
|
|
197
|
+
|
|
198
|
+
Key-value pairs for objects, tables for arrays.
|
|
199
|
+
|
|
200
|
+
## Exit Codes
|
|
201
|
+
|
|
202
|
+
| Code | Meaning |
|
|
203
|
+
|------|---------|
|
|
204
|
+
| 0 | Success (check `success` field – action may have returned an error like "person not found") |
|
|
205
|
+
| 1 | General/unexpected error |
|
|
206
|
+
| 2 | Missing or invalid tokens |
|
|
207
|
+
| 3 | Subscription/plan required |
|
|
208
|
+
| 4 | LinkedIn account issue |
|
|
209
|
+
| 5 | Invalid arguments |
|
|
210
|
+
| 6 | Rate limited |
|
|
211
|
+
| 7 | Network error |
|
|
212
|
+
| 8 | Workflow timeout (workflowId returned for recovery) |
|
|
213
|
+
|
|
214
|
+
## Important Notes
|
|
215
|
+
|
|
216
|
+
- **Sequential execution.** Linked API executes all workflows sequentially per account. You can send multiple requests, but they queue and run one at a time. This mirrors natural LinkedIn user behavior.
|
|
217
|
+
- **Not instant.** Simple operations (fetch a profile) take ~10-20 seconds. Complex operations (search with filters) can take longer. This is because a real cloud browser navigates LinkedIn on your behalf.
|
|
218
|
+
- **Timestamps in UTC.** All dates and times returned by the API are in UTC.
|
|
219
|
+
- **URL normalization.** All LinkedIn URLs in responses are normalized to `https://www.linkedin.com/...` format without trailing slashes.
|
|
220
|
+
- **Null fields.** Fields that are unavailable are returned as `null` or `[]`, not omitted.
|
|
221
|
+
- **Action limits.** Configurable per-account action limits on the [platform](https://app.linkedapi.io) prevent LinkedIn policy violations. When a limit is reached, you get a `limitExceeded` error.
|
|
222
|
+
|
|
223
|
+
See [Core Concepts](https://linkedapi.io/docs/core-concepts) for more details.
|
|
224
|
+
|
|
225
|
+
## For AI Agents
|
|
226
|
+
|
|
227
|
+
This CLI is designed for AI agent consumption:
|
|
228
|
+
|
|
229
|
+
- `--json` flag gives structured output parseable with `jq`
|
|
230
|
+
- Non-TTY stdout auto-switches to JSON
|
|
231
|
+
- `--quiet` suppresses all stderr noise
|
|
232
|
+
- `--fields` reduces output to only needed data
|
|
233
|
+
- Exit code 0 always means "API call succeeded" – parse `success` field for action outcome
|
|
234
|
+
- Non-zero exits = infrastructure errors (auth, network, etc.)
|
|
235
|
+
|
|
236
|
+
Example agent usage:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Set up authentication
|
|
240
|
+
linkedin setup --linked-api-token=xxx --identification-token=yyy
|
|
241
|
+
|
|
242
|
+
# Fetch just name and headline
|
|
243
|
+
linkedin person fetch https://www.linkedin.com/in/john-doe --json --fields name,headline -q
|
|
244
|
+
|
|
245
|
+
# Pipe to jq
|
|
246
|
+
linkedin person search --term "engineer" --json -q | jq '.data[].name'
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Links
|
|
250
|
+
|
|
251
|
+
- [Linked API Documentation](https://linkedapi.io/docs)
|
|
252
|
+
- [Getting Started](https://linkedapi.io/docs/getting-started)
|
|
253
|
+
- [Safety & Security](https://linkedapi.io/safety)
|
|
254
|
+
- [Node.js SDK](https://www.npmjs.com/package/linkedapi-node)
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@linkedapi/linkedin-cli",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "AI-agent-friendly CLI for LinkedIn automation via Linked API",
|
|
5
|
+
"author": "Linked API",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://linkedapi.io",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Linked-API/linkedin-cli"
|
|
11
|
+
},
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"linkedin": "./bin/run.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"bin",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"oclif.manifest.json"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc && tsc-alias && npm run manifest",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"lint": "eslint src --fix",
|
|
30
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
31
|
+
"manifest": "oclif manifest",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
34
|
+
"prepare": "husky",
|
|
35
|
+
"postpack": "rm -f oclif.manifest.json"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"linkedin",
|
|
39
|
+
"cli",
|
|
40
|
+
"api",
|
|
41
|
+
"automation",
|
|
42
|
+
"linkedapi",
|
|
43
|
+
"ai-agent"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@linkedapi/node": "^1.2.15",
|
|
47
|
+
"@oclif/core": "^4.2.10"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@eslint/compat": "^1.2.5",
|
|
51
|
+
"@eslint/js": "^9.24.0",
|
|
52
|
+
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
53
|
+
"@types/node": "^22.14.0",
|
|
54
|
+
"eslint": "^9.24.0",
|
|
55
|
+
"eslint-plugin-import": "^2.31.0",
|
|
56
|
+
"eslint-plugin-n": "^17.16.2",
|
|
57
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
58
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
59
|
+
"globals": "^16.0.0",
|
|
60
|
+
"husky": "^9.1.7",
|
|
61
|
+
"oclif": "^4.17.0",
|
|
62
|
+
"prettier": "^3.5.3",
|
|
63
|
+
"tsc-alias": "^1.8.10",
|
|
64
|
+
"typescript": "^5.8.3",
|
|
65
|
+
"typescript-eslint": "^8.29.0"
|
|
66
|
+
},
|
|
67
|
+
"oclif": {
|
|
68
|
+
"bin": "linkedin",
|
|
69
|
+
"dirname": "linkedin-cli",
|
|
70
|
+
"commands": "./dist/commands",
|
|
71
|
+
"topicSeparator": " ",
|
|
72
|
+
"topics": {
|
|
73
|
+
"account": {
|
|
74
|
+
"description": "Manage connected LinkedIn accounts"
|
|
75
|
+
},
|
|
76
|
+
"person": {
|
|
77
|
+
"description": "Fetch and search LinkedIn profiles"
|
|
78
|
+
},
|
|
79
|
+
"company": {
|
|
80
|
+
"description": "Fetch and search LinkedIn companies"
|
|
81
|
+
},
|
|
82
|
+
"message": {
|
|
83
|
+
"description": "Send and retrieve LinkedIn messages"
|
|
84
|
+
},
|
|
85
|
+
"connection": {
|
|
86
|
+
"description": "Manage LinkedIn connections"
|
|
87
|
+
},
|
|
88
|
+
"post": {
|
|
89
|
+
"description": "Manage LinkedIn posts"
|
|
90
|
+
},
|
|
91
|
+
"stats": {
|
|
92
|
+
"description": "Retrieve LinkedIn statistics"
|
|
93
|
+
},
|
|
94
|
+
"navigator": {
|
|
95
|
+
"description": "Sales Navigator operations"
|
|
96
|
+
},
|
|
97
|
+
"navigator:person": {
|
|
98
|
+
"description": "Sales Navigator person operations"
|
|
99
|
+
},
|
|
100
|
+
"navigator:company": {
|
|
101
|
+
"description": "Sales Navigator company operations"
|
|
102
|
+
},
|
|
103
|
+
"navigator:message": {
|
|
104
|
+
"description": "Sales Navigator messaging"
|
|
105
|
+
},
|
|
106
|
+
"workflow": {
|
|
107
|
+
"description": "Execute custom workflows"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"engines": {
|
|
112
|
+
"node": ">=20.0.0"
|
|
113
|
+
}
|
|
114
|
+
}
|