lnkn-cli
v0.8.0
Published
CLI para publicar y gestionar posts de LinkedIn (OAuth API + Playwright fallback)
Maintainers
Readme
linkedin-cli
Roadmap completo: GUIA.md
CLI para publicar y gestionar posts de LinkedIn desde la terminal. Soporta la API oficial OAuth (recomendado) y Playwright como fallback para analytics y posting legacy.
Instalacion
Desde npm (recomendado)
npm install -g lnkn-cli
npx playwright install chromium # solo si usas modo PlaywrightDesde el repo
git clone https://github.com/mayckolco/linkedin-cli.git
cd linkedin-cli
npm install
npx playwright install chromium
npm linkSetup OAuth (recomendado)
Cada usuario necesita su propia LinkedIn Developer App. No compartas client_id / client_secret.
- Crea una app en LinkedIn Developer Portal
- Activa Sign In with LinkedIn using OpenID Connect y Share on LinkedIn
- Registra el redirect URI:
http://127.0.0.1:8765/callback - Configura credenciales:
linkedin auth init --client-id TU_CLIENT_ID --client-secret TU_CLIENT_SECRET
linkedin auth login
linkedin whoamiGuia detallada: docs/SETUP-OAUTH.md
Tokens en ~/.linkedin-cli/credentials.json (permisos 600). El token dura ~60 dias; sin refresh_token debes repetir linkedin auth login.
Transportes: API vs Playwright
| Caso | Transporte | Comando |
|------|------------|---------|
| Publicar texto, imagen, video, documento, reshare | API OAuth | linkedin post text/image/... --confirm |
| Publicar desde archivo .txt | API (recomendado) | linkedin post file draft.txt --transport api --confirm |
| Publicar desde archivo .txt | Playwright (legacy) | linkedin post file draft.txt --confirm |
| Analytics del dashboard | Playwright | linkedin analytics |
| Login rapido sin Developer App | Playwright | linkedin login |
Recomendacion: usa API OAuth para todo posting. Playwright se mantiene como fallback y para analytics (scraping), con riesgo de rotura de selectores y ToS de automatizacion.
Comandos — Auth
| Comando | Descripcion |
|---------|-------------|
| linkedin auth init | Guardar client_id/secret |
| linkedin auth login | Flujo OAuth |
| linkedin auth refresh | Refrescar token (si hay refresh_token) |
| linkedin auth profiles | Listar perfiles OAuth |
| linkedin auth use <name> | Cambiar perfil activo |
| linkedin auth status | Estado del token |
| linkedin auth logout | Borrar credenciales |
| linkedin whoami | Perfil autenticado |
Variables: LINKEDIN_CLI_PROFILE, LINKEDIN_CLI_DATA, LINKEDIN_API_VERSION (default 202508).
Comandos — Posting (API)
Sin --confirm siempre hace dry-run.
# Texto
linkedin post text "Mi update" --confirm --log
# Desde archivo
linkedin post file borrador.txt --transport api --confirm --log
# Imagen (jpg, png, gif — debe ser archivo valido)
linkedin post image --file foto.png --text "Caption" --confirm
# Video (mp4, mov)
linkedin post video --file clip.mp4 --text "Caption" --title "Titulo" --confirm
# Documento (pdf, doc, ppt)
linkedin post document --file guia.pdf --title "Guia" --text "Caption" --confirm
# Reshare
linkedin post reshare urn:li:share:123456789 --text "Recomiendo" --confirm
# Borrar
linkedin post delete urn:li:share:123456789 --confirmAlias: linkedin post borrador.txt equivale a linkedin post file borrador.txt.
Migrar desde autopost-v2
linkedin migrate autopost-v2 --dry-run
linkedin migrate autopost-v2Ver docs/AUTOPOST-V2.md y docs/AGENTS.md.
Comandos — Borradores, historial, panel
| Comando | Descripcion |
|---------|-------------|
| linkedin draft save/list/show | Gestionar borradores |
| linkedin history list/add | Historial de posts |
| linkedin schedule create/list/cancel | Programar (Windows) |
| linkedin serve --open | Panel web local |
| linkedin analytics | Scrape Playwright (prototipo, disclaimer ToS) |
| linkedin analytics post <urn> | Metricas de un post via API |
| linkedin analytics me | Metricas agregadas via API |
| linkedin analytics export | Exportar snapshots JSON/CSV |
| linkedin mcp | Servidor MCP (stdio) para agentes — docs/MCP.md |
MCP (agentes)
Expone el CLI como herramientas MCP para Cursor o Claude Desktop:
linkedin mcp
# o
linkedin-mcpConfiguracion y tools: docs/MCP.md. Salida --json para integraciones custom: docs/AGENTS.md.
Limites de la API
| Recurso | Limite |
|---------|--------|
| Texto del post | 3 000 caracteres |
| Imagen | JPG, PNG, GIF; < 36 MPixeles |
| Video | MP4/MOV; hasta 5 GB |
| Documento | PDF, DOC, PPT; hasta 100 MB |
| Token OAuth | ~60 dias (re-auth manual sin refresh_token) |
| Permisos posting | w_member_social + OpenID scopes |
| Leer posts propios via API | Requiere r_member_social (restringido) |
| Analytics por post via API | Requiere r_member_postAnalytics — guia |
Datos locales
~/.linkedin-cli/
config.json # perfil OAuth activo
app.json # client_id/secret (NO commitear)
apps/<profile>.json
credentials.json # tokens OAuth (NO commitear)
drafts/<profile>/
history/<profile>/posts-log.jsonl
profile/ # sesion Playwright
analytics/Override: --data-dir o LINKEDIN_CLI_DATA.
Publicar en npm (maintainers)
Ver docs/PUBLISH.md.
Desarrollo
npm test
node bin/linkedin.js --helpLicencia
MIT — ver LICENSE.
