npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

linkedin-ads-cli

v1.0.4

Published

LinkedIn Ads CLI for AI agents

Readme

linkedin-ads-cli

LinkedIn Ads CLI for AI agents (and humans). Pull campaign analytics with pivot breakdowns, forecast ad delivery and budgets, explore targeting facets, retrieve lead form responses, and more.

Works with: OpenClaw, Claude Code, Cursor, Codex, and any agent that can run shell commands.

Installation

npm install -g linkedin-ads-cli

Or run directly: npx linkedin-ads-cli --help

How it works

Built on the official LinkedIn Marketing API, this CLI authenticates via an OAuth2 Bearer token (set as an environment variable, credentials file, or per-command flag) and provides read-only access to LinkedIn's advertising platform.

Core endpoints covered:

  • Organizations & accounts -- authenticated user profile, organizations, ad accounts, and account users
  • Campaign groups & campaigns -- browse the campaign hierarchy with status filtering
  • Creatives -- list and inspect ad creatives with campaign filtering
  • Analytics & reporting -- pull performance metrics with date ranges, granularity (daily/monthly), and pivot dimensions
  • Audiences & targeting -- matched audiences, audience counts, and available targeting facets
  • Conversions & tracking -- conversion rules and Insight Tags
  • Lead gen -- lead gen forms and form responses with time-range filtering
  • Forecasting -- budget recommendations and ad delivery forecasts

Setup

Option 1: Environment variable

export LINKEDIN_ADS_ACCESS_TOKEN="your_access_token"

Option 2: Credentials file

Create ~/.config/linkedin-ads-cli/credentials.json:

{
  "access_token": "your_access_token"
}

Option 3: Per-command credentials

linkedin-ads-cli accounts --credentials /path/to/creds.json

Getting an access token

LinkedIn requires OAuth2 authentication. You need a LinkedIn Developer Application with Marketing API access. Use the OAuth2 flow to get an access token with the required scopes:

  • r_ads - Read ad accounts
  • r_ads_reporting - Read ad analytics
  • r_organization_social - Read organization data

Entity hierarchy

LinkedIn Ads uses this hierarchy:

Organization (Company Page)
 └── Ad Account
      └── Campaign Group
           └── Campaign
                └── Creative

Most list commands require the parent entity ID. Start with me to get your profile, then organization-acls to find organizations you manage, then accounts to find ad accounts.

Usage

All commands output pretty-printed JSON by default. Use --format compact for single-line JSON.

LinkedIn uses URN format for IDs (e.g., urn:li:sponsoredAccount:123456). This CLI accepts both full URNs and plain numeric IDs.

me

Get the authenticated user profile.

linkedin-ads-cli me

organization

Get an organization (company page) by ID.

linkedin-ads-cli organization 12345678

organization-acls

List organizations the authenticated user administers.

linkedin-ads-cli organization-acls
linkedin-ads-cli organization-acls --role ADMINISTRATOR

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)
  • --role <role> -- filter by role: ADMINISTRATOR, DIRECT_SPONSORED_CONTENT_POSTER, etc.

accounts

List ad accounts the authenticated user has access to.

linkedin-ads-cli accounts
linkedin-ads-cli accounts --search "My Company"

Options:

  • --page-size <n> -- results per page (default 100)
  • --page-token <token> -- page token for pagination
  • --search <query> -- search by account name or ID

account

Get a specific ad account.

linkedin-ads-cli account 123456789
linkedin-ads-cli account urn:li:sponsoredAccount:123456789

account-users

List users with access to an ad account.

linkedin-ads-cli account-users 123456789

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)

campaign-groups

List campaign groups for an ad account.

linkedin-ads-cli campaign-groups 123456789

Options:

  • --page-size <n> -- results per page (default 100)
  • --page-token <token> -- page token for pagination

campaign-group

Get a specific campaign group.

linkedin-ads-cli campaign-group 987654321

campaigns

List campaigns for an ad account.

linkedin-ads-cli campaigns 123456789
linkedin-ads-cli campaigns 123456789 --status ACTIVE

Options:

  • --page-size <n> -- results per page (default 100)
  • --page-token <token> -- page token for pagination
  • --status <status> -- filter by status: ACTIVE, PAUSED, ARCHIVED, COMPLETED, CANCELED, DRAFT
  • --campaign-group <id> -- filter by campaign group ID

campaign

Get a specific campaign.

linkedin-ads-cli campaign 111222333

creatives

List creatives for an ad account.

linkedin-ads-cli creatives 111222333

Options:

  • --page-size <n> -- results per page (default 100)
  • --page-token <token> -- page token for pagination
  • --campaign <campaign-id> -- filter by campaign ID

creative

Get a specific creative.

linkedin-ads-cli creative 444555666

audiences

List matched audiences (DMP segments) for an ad account.

linkedin-ads-cli audiences 123456789

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)

conversion-rules

List conversion rules for an ad account.

linkedin-ads-cli conversion-rules 123456789

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)

insight-tags

List LinkedIn Insight Tags for an ad account.

linkedin-ads-cli insight-tags 123456789

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)

analytics

Get ad analytics for an account.

linkedin-ads-cli analytics 123456789 --start-date 2026-01-01 --end-date 2026-01-31
linkedin-ads-cli analytics 123456789 --start-date 2026-01-01 --end-date 2026-01-31 --granularity DAILY --pivot CAMPAIGN

Options:

  • --start-date <date> -- start date (YYYY-MM-DD) required
  • --end-date <date> -- end date (YYYY-MM-DD) required
  • --granularity <gran> -- time granularity: DAILY, MONTHLY, ALL (default DAILY)
  • --pivot <pivot> -- pivot dimension: CAMPAIGN, CAMPAIGN_GROUP, CREATIVE, ACCOUNT (default CAMPAIGN)
  • --campaign-ids <ids> -- filter by campaign IDs (comma-separated)
  • --campaign-group-ids <ids> -- filter by campaign group IDs (comma-separated)
  • --fields <fields> -- metric fields (comma-separated)

Default metrics: impressions, clicks, costInLocalCurrency, costInUsd, externalWebsiteConversions, likes, comments, shares, follows, videoViews

lead-gen-forms

List Lead Gen forms for an ad account.

linkedin-ads-cli lead-gen-forms 123456789

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)

lead-form-responses

List lead form responses (submissions) for an ad account.

linkedin-ads-cli lead-form-responses 123456789
linkedin-ads-cli lead-form-responses 123456789 --form 777888999
linkedin-ads-cli lead-form-responses 123456789 --start-time 1709251200000 --end-time 1711929600000

Options:

  • --count <n> -- results per page (default 100)
  • --start <n> -- start index (default 0)
  • --form <form-id> -- filter by form ID
  • --start-time <time> -- filter responses after this time (epoch ms)
  • --end-time <time> -- filter responses before this time (epoch ms)

audience-counts

Get estimated audience size for targeting criteria.

linkedin-ads-cli audience-counts 123456789

budget-recommendations

Get budget recommendations for a campaign.

linkedin-ads-cli budget-recommendations 111222333

ad-forecasts

Get ad delivery forecasts for an account.

linkedin-ads-cli ad-forecasts 123456789

targeting-facets

List available targeting facets (industries, job titles, locations, etc.).

linkedin-ads-cli targeting-facets

Error output

All errors are JSON to stderr:

{"error": "No credentials found. Set LINKEDIN_ADS_ACCESS_TOKEN env var..."}

API Reference

Related

License

Apache-2.0