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 🙏

© 2025 – Pkg Stats / Ryan Hefner

authorsight-export

v0.0.2

Published

A CLI utility that allows you to export books sales data from Packt AuthorSight for your own historic backup and analysis

Readme

authorsight-export 📦

npm version CI

A CLI tool to fetch and export book sales and revenue data from the Packt AuthorSight portal in Hive-compatible format.

Rationale 💡

Hi there, fellow Packt author! 👋

Chances are, if you’ve landed here, you’re looking for a way to make better use of the data in the AuthorSight portal. Same here!

I’m Luciano Mammino, a software engineer and co-author of Node.js Design Patterns. (Shameless plug, but it might be useful if you're looking to improve your Node.js game!)

As authors, we get access to Packt AuthorSight: a handy dashboard with our sales and royalty data, but sometimes you just want that information in a more flexible format. Maybe you want to run your own analysis, generate custom reports, integrate it with other tools, or just keep a tidy archive.

That’s exactly why I built this little tool. If you're looking to export your Packt sales data quickly and cleanly, you're in the right place.

Hope it helps and happy hacking! 🚀

Features ✨

  • Fetch Kindle and Print sales data (Amazon, Direct, Other)
  • Supports multiple data types:
    • amazon_units_daily
    • direct_units_daily
    • revenue_monthly
    • revenue_quarterly
    • revenue_annual
  • Exports data in a directory structure by book and year (hive-compatible for supporting tools like Apache Hive, DuckDB, AWS Athena, etc.)
  • Progress bars, retry and robust error handling

Installation 🛠️

You can use this tool directly with npx (recommended):

npx authorsight-export --session <cookie> [options]

Or, install globally:

npm install -g authorsight-export

Or, clone the repository and install dependencies:

git clone https://github.com/yourusername/authorsight-export.git
cd authorsight-export
npm install

Usage 🚀

With npx (recommended)

export AUTHORSIGHT_SESSION=<cookie>

[!IMPORTANT]
Make sure to replace <cookie> with your actual Packt authorsight_session and that the value is URL-decoded (e.g., no %20 for spaces). You can find this cookie in your browser's developer tools under the "Application" tab after logging in on the Packt AuthorSight portal.

Then run:

npx authorsight-export [options]

[!CAUTION]
You can also pass your session cookie inline using the --session option. This is discouraged, and it is instead recommended setting your session cookie using the AUTHORSIGHT_SESSION environment variable. This is more secure and avoids leaking sensitive information in shell history.

Options ⚙️

  • -s, --session <cookie>: Packt authorsight_session cookie (discouraged; use the AUTHORSIGHT_SESSION environment variable instead)
  • -o, --output <directory>: Output directory (default: .)
  • -b, --books <bookIds>: Comma-separated list of book IDs (default: all books)
  • -t, --types <types>: Comma-separated list of data types to fetch (default: all)
  • -V, --version: Show CLI version
  • -h, --help: Show help message

Example 💡

AUTHORSIGHT_SESSION=YOUR_SESSION_COOKIE npx authorsight-export -b B05259,C09167 -t revenue_monthly,revenue_annual -o ./output

Data Types 📊

| Type | Endpoint | Description | | ------------------ | ------------ | ------------------ | | amazon_units_daily | amazon-daily | Daily Amazon units | | direct_units_daily | direct-daily | Daily Direct units | | revenue_monthly | monthly | Monthly revenue | | revenue_quarterly | quarterly | Quarterly revenue | | revenue_annual | annual | Annual revenue |

DuckDB query example 🦆

Just to provide an example of how you can query the exported data using DuckDB, the following SQL query sums the total print and digital units across all books and data types (amazon and direct):

SELECT SUM(print_units + digital_units) FROM (
  SELECT book, date, month, year, print_units, kindle_units AS digital_units FROM read_csv('amazon_units_daily/**/*.csv')
  UNION
  SELECT book, date, month, year, print_units, digital_units FROM read_csv('direct_units_daily/**/*.csv')
)

Contributing 🤝

Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub. PRs are also very welcome.

License 📄

Licensed under MIT License. © Luciano Mammino.