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

@mirage-cli/ahrefs-cli

v0.1.11

Published

Ahrefs API v3 — CLI and programmatic library. Mirage-compatible command shape.

Readme

ahrefs-cli

CLI and programmatic library for the Ahrefs API v3. Maps cleanly to the web UI. Outputs in colored tables, JSON, or CSV. Command shape is structurally compatible with @struktoai/mirage-core — commands authored here can be lifted into a Mirage workspace without rewrite.

$ ahrefs keywords overview --select "keyword,country,volume,difficulty,cpc" "vegan protein"
  keyword         country   volume    difficulty   cpc
  vegan protein   us        74,000    58           $2.10

Install

git clone [email protected]:alexbruf/mirage-cli.git
cd mirage-cli
bun install
bun run --filter ahrefs-cli build
ln -sf "$PWD/packages/ahrefs-cli/dist/cli.js" /usr/local/bin/ahrefs   # or anywhere on $PATH

Or if you're consuming it programmatically in another project:

bun add ahrefs-cli

Auth

Create an API v3 key at https://app.ahrefs.com/account/api-keys (scope: API v3, not MCP). Then either drop it in .env:

echo "AHREFS_API_KEY=your_key_here" > .env

…or export it in your shell, or pass --api-key <key> per-command. Verify:

ahrefs account limits

Usage

bun run src/cli.ts <section> <command> [args] [flags]

Sections mirror the Ahrefs web UI:

| Section | Commands | |---|---| | site-explorer | overview, backlinks, refdomains, organic-keywords, organic-competitors, top-pages, anchors, ... | | keywords | overview, matching-terms, related-terms, search-suggestions, volume-history, volume-by-country | | rank-tracker | overview, serp-overview, competitors-overview, competitors-pages, competitors-stats | | site-audit | projects, issues, page-content, page-explorer | | batch-analysis | (top-level: ahrefs batch-analysis ...) | | gsc | keywords, pages, performance-history, ... | | account | limits |

Run ahrefs <section> --help to list commands. Run ahrefs <section> <command> --help for full per-flag documentation pulled straight from the Ahrefs OpenAPI spec — including types, enum values, defaults, and descriptions.

Output formats

  • Table (default) — colored, aligned, ergonomic.
  • --json — raw API response, composable with jq.
  • --csv — header + rows, pipe-friendly.

Useful global flags

  • --cache 1h — cache GET responses on disk (~/.cache/ahrefs-cli/) for the given duration. Big deal because every call costs Ahrefs API units.
  • --explain — print the equivalent curl command to stderr before calling.
  • --select col1,col2,... — override the default column set for any list endpoint. Affects unit cost.

Help is the source of truth

The CLI's help text is generated from a bundled snapshot of the Ahrefs OpenAPI spec (openapi/ahrefs.json), crawled from docs.ahrefs.com. To refresh:

bun run tools/build-spec.ts        # re-crawl spec
bunx openapi-typescript openapi/ahrefs.json -o src/generated/api-types.ts

Programmatic use

Same command definitions power the CLI and the library. Call them in-process via invoke() — no subprocess.

import { invoke, keywordsOverviewCmd } from "@mirage-cli/ahrefs-cli";

const { text, result } = await invoke(keywordsOverviewCmd, {
  flags: { country: "us", json: true },
  texts: ["vegan protein"],
});
console.log(text);
console.log("exit:", result.exitCode);

// Or pass argv tokens, like the CLI would receive
await invoke(keywordsOverviewCmd, ["--country", "us", "--json", "vegan protein"]);

For raw API access (without a command's flag-parsing layer):

import { request } from "@mirage-cli/ahrefs-cli";

const data = await request({
  path: "/keywords-explorer/overview",
  query: { select: "keyword,volume,difficulty", country: "us", keywords: "vegan protein" },
});

Claude Code skill

A short "want X → run Y" reference lives at skills/ahrefs/SKILL.md. To make Claude Code see it across sessions, symlink it into ~/.claude/skills/:

ln -s "$(pwd)/skills/ahrefs" ~/.claude/skills/ahrefs

Full per-flag docs stay in ahrefs <cmd> --help.

License

MIT.