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

applemusic-cli

v1.0.0

Published

Control Apple Music from the terminal (macOS)

Readme

Apple Music CLI

Control Apple Music from the terminal using AppleScript (macOS only).

Install

bun install

Usage

# Using alias (add to fish config)
alias am "bun run /path/to/src/index.ts"

# Playback
am play          # Start playback
am pause         # Pause
am toggle        # Toggle play/pause
am next          # Next track
am prev          # Previous track

# Now playing
am now           # Show current track info

# Volume
am vol           # Get volume
am vol 50        # Set volume to 50%

# Playlists
am playlists                    # List all playlists
am playlist "My Playlist"       # Play a playlist
am tracks "My Playlist"         # List tracks in playlist

# Library
am songs                        # List all songs
am search nirvana               # Search library
am song "Come As You Are"       # Play a song by name

# Options
am shuffle on                   # Enable shuffle
am repeat all                   # Set repeat mode (off/one/all)

# Pagination (works with playlists, tracks, songs, search)
am songs --limit 20 --offset 40
am search rock --limit 10

Architecture

src/
├── index.ts              # CLI entry point - parses command and dispatches
├── osascript.ts          # AppleScript execution helpers
├── args.ts               # Command-line argument parsing utilities
├── pagination.ts         # Pagination utilities for list commands
└── commands/
    ├── index.ts          # Command registry - maps names to handlers
    ├── playback.ts       # play, pause, stop, next, prev, toggle
    ├── now.ts            # Current track info display
    ├── volume.ts         # Volume get/set
    ├── playlists.ts      # Playlist listing and playback
    ├── library.ts        # Library browsing and search
    ├── options.ts        # Shuffle and repeat settings
    └── help.ts           # Help text display

Module Overview

| Module | Description | |--------|-------------| | osascript | Low-level AppleScript execution via osascript command | | args | Parses --flag value and positional arguments | | pagination | Generic pagination with limit/offset support | | commands/* | Individual command implementations |

Adding a New Command

  1. Create a new file in src/commands/ (or add to existing file)
  2. Export an async function matching the Command type signature
  3. Register it in src/commands/index.ts
  4. Update help text in src/commands/help.ts

Example:

// src/commands/mycommand.ts
import { osascript } from "../osascript";

export async function myCommand(): Promise<void> {
  const result = await osascript('tell application "Music" to ...');
  console.log(result);
}

// src/commands/index.ts
import { myCommand } from "./mycommand";

export const commands: Record<string, Command> = {
  // ...
  mycommand: () => myCommand(),
};

Limitations

  • Local library only: Search and listing only work with downloaded/local tracks, not streaming catalog
  • No radio/recommendations: AppleScript can't access Apple Music radio stations or personalized recommendations
  • macOS only: Uses AppleScript under the hood

TODO

  • [ ] MusicKit integration for accessing Apple Music streaming features (radio, recommendations, full catalog search)
    • Requires Apple Developer account and signing keys
    • Would enable: Discovery Station, personal mixes, radio stations
    • Reference: https://developer.apple.com/musickit/