JSPM

@promobase/linkedin-sdk

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q50971F
  • License MIT

Type-safe TypeScript SDK for LinkedIn organic publishing and OAuth

Package Exports

  • @promobase/linkedin-sdk

Readme

@promobase/linkedin-sdk

Type-safe TypeScript SDK for LinkedIn organic publishing and OAuth.

LinkedIn does not currently publish a public OpenAPI/Swagger spec or public per-endpoint Rest.li restspec for the Marketing API surfaces this package wraps. This SDK is hand-authored against the official Microsoft Learn endpoint docs and LinkedIn's Rest.li protocol documentation.

Install

bun add @promobase/linkedin-sdk
# or
npm install @promobase/linkedin-sdk

Use

import { LinkedIn } from "@promobase/linkedin-sdk";

const linkedin = LinkedIn.createClient({
  accessToken: process.env.LINKEDIN_ACCESS_TOKEN!,
});

const result = await linkedin.posts.createText({
  authorUrn: "urn:li:organization:123456",
  commentary: "New launch is live.",
});

console.log(result.postUrn);

Publish Media

const imageUrn = await linkedin.assets.uploadImageFromUrl(
  "urn:li:organization:123456",
  "https://cdn.example.com/photo.jpg",
);

await linkedin.posts.createImage({
  authorUrn: "urn:li:organization:123456",
  commentary: "Behind the scenes.",
  imageUrn,
  options: { altText: "A team photo" },
});

OAuth

const oauth = LinkedIn.OAuth.create({
  clientId: process.env.LINKEDIN_CLIENT_ID!,
  clientSecret: process.env.LINKEDIN_CLIENT_SECRET!,
  redirectUri: "https://app.example.com/oauth/linkedin/callback",
});

const url = oauth.getAuthorizationUrl({ state: "opaque-state" });

Official References