← Back to CLIs
Melvynx

posthog-cli

Manage PostHog via CLI - dashboards, insights, events, persons, feature-flags, queries, annotations, actions, cohorts, exports. Use when user mentions 'posthog', 'analytics dashboard', 'pageviews', 'feature flags', 'HogQL query', 'event tracking', 'funnel analysis', 'cohort', 'insight', or wants to interact with PostHog analytics data.

Install

$ npx api2cli install Melvynx/posthog-cli

Details

Skill type: Wrapper CLI
Auth type: api-key
Version: 0.1.0
Author: Melvynx
Views: 0

README

posthog-cli

CLI for the PostHog analytics API. Made with api2cli.dev.

Install

npx api2cli install Melvynx/posthog-cli

This clones the repo, builds the CLI, links it to your PATH, and installs the AgentSkill to your coding agents.

Install AgentSkill only

npx skills add Melvynx/posthog-cli

Usage

posthog-cli auth set "phx_your-personal-api-key"
posthog-cli auth test
posthog-cli --help

Resources

dashboards

CommandDescription
posthog-cli dashboards list --jsonList all dashboards
posthog-cli dashboards get <id> --jsonGet a dashboard by ID
posthog-cli dashboards create --name "My Dashboard" --jsonCreate a dashboard
posthog-cli dashboards update <id> --name "New Name" --jsonUpdate a dashboard
posthog-cli dashboards delete <id> --jsonSoft-delete a dashboard
posthog-cli dashboards sharing <id> --jsonGet sharing config
posthog-cli dashboards copy-tile <target-id> --from <src-id> --tile <tile-id> --jsonCopy tile

insights

CommandDescription
posthog-cli insights list --jsonList all insights
posthog-cli insights get <id> --jsonGet an insight by ID
posthog-cli insights create --name "My Insight" --jsonCreate an insight
posthog-cli insights update <id> --name "Updated" --jsonUpdate an insight
posthog-cli insights delete <id> --jsonSoft-delete an insight
posthog-cli insights activity <id> --jsonGet activity log

events

CommandDescription
posthog-cli events list --jsonList recent events
posthog-cli events list --event "$pageview" --jsonFilter by event name
posthog-cli events get <id> --jsonGet a single event
posthog-cli events values --event "$pageview" --property "$browser" --jsonGet property values

persons

CommandDescription
posthog-cli persons list --jsonList persons
posthog-cli persons list --search "user@email.com" --jsonSearch persons
posthog-cli persons get <uuid> --jsonGet a person
posthog-cli persons delete <uuid> --jsonDelete a person
posthog-cli persons properties --jsonList person property keys

feature-flags

CommandDescription
posthog-cli feature-flags list --jsonList all flags
posthog-cli feature-flags get <id> --jsonGet a flag
posthog-cli feature-flags create --key "feat" --name "Feature" --jsonCreate a flag
posthog-cli feature-flags update <id> --active true --jsonEnable a flag
posthog-cli feature-flags delete <id> --jsonDelete a flag

queries

CommandDescription
posthog-cli queries run --query "SELECT event, count() FROM events GROUP BY event LIMIT 10" --jsonHogQL query
posthog-cli queries events --event "$pageview" --jsonQuick event query
posthog-cli queries trends --event "$pageview" --interval day --jsonTrends query
posthog-cli queries funnels --events "$pageview,sign_up" --jsonFunnel analysis

annotations

CommandDescription
posthog-cli annotations list --jsonList annotations
posthog-cli annotations create --content "Deploy v2" --date "2024-03-15T00:00:00Z" --jsonCreate
posthog-cli annotations delete <id> --jsonDelete

actions

CommandDescription
posthog-cli actions list --jsonList actions
posthog-cli actions create --name "Sign Up" --jsonCreate
posthog-cli actions delete <id> --jsonDelete

cohorts

CommandDescription
posthog-cli cohorts list --jsonList cohorts
posthog-cli cohorts create --name "Power Users" --jsonCreate
posthog-cli cohorts delete <id> --jsonDelete

exports

CommandDescription
posthog-cli exports list --jsonList exports
posthog-cli exports create --dashboard <id> --format-type "image/png" --jsonExport dashboard

Global Flags

All commands support: --json, --format <text|json|csv|yaml>, --verbose, --no-color, --no-header, --env <id>

Sponsors