Zero-dependency, offline cat facts for Node.js. Get a random fact, a fact of the day, or search 108 curated facts, from code or the command line.
βΆ Try it live in your browser: random facts, the fact of the day and search, with no install.
βΆ Watch the 49-second demo on YouTube. More short package videos on @gykhdev. Sibling packages: @gykh/morse, @gykh/enigma, @gykh/vigenere-cipher, @gykh/caesar-cipher. All packages: @gykh on npm.
npx @gykh/cat-facts
π± A group of cats is called a clowder.- Features
- Install
- Usage
- CLI
- API Reference
- Upgrading from v1
- Interactive Demo
- More from the Author: MiniFyn
- Developer
- License
- π Zero Dependencies: Pure JavaScript, nothing else to install.
- π΄ Works Offline: 108 curated facts ship inside the package. No API, no rate limits, no outages.
- π² Unique Random Picks:
facts(5)never repeats a fact. - π Fact of the Day: The same fact for everyone on a given UTC day, perfect for bots and dashboards.
- π Search: Case-insensitive search across every fact.
- π» CLI:
npx @gykh/cat-factsfor a quick fact in your terminal or shell greeting. - π TypeScript Ready: Bundled type definitions, CommonJS and ESM entries.
- β»οΈ v1 Compatible: The default export still takes a callback, and now returns a Promise too.
# pnpm
pnpm add @gykh/cat-facts
# npm
npm install @gykh/cat-facts
# yarn
yarn add @gykh/cat-factsRequires Node.js 18 or later.
// ESM
import { randomFact, facts, factOfTheDay, search, count } from '@gykh/cat-facts';
// CommonJS
const { randomFact, facts, factOfTheDay, search, count } = require('@gykh/cat-facts');
randomFact();
// 'Cats have a third eyelid, called the nictitating membrane, that helps protect the eye.'
facts(3);
// three different facts
factOfTheDay();
// the same fact all day (UTC), a new one tomorrow
search('purr');
// every fact that mentions purring
count; // 108The v1 default export still works:
import catFacts from '@gykh/cat-facts';
const { text } = await catFacts();
catFacts((err, fact) => console.log(fact.text));npx @gykh/cat-facts # one random fact
npx @gykh/cat-facts 5 # five unique facts
npx @gykh/cat-facts --today # fact of the day
npx @gykh/cat-facts --search tail
npx @gykh/cat-facts 3 --json # JSON array, handy for scriptsInstall it globally (npm i -g @gykh/cat-facts) and add cat-facts to your ~/.zshrc or ~/.bashrc for a fact every time you open a terminal.
| Option | Description |
|---|---|
n |
Print n unique random facts (default 1) |
-t, --today |
Print the fact of the day |
-s, --search <q> |
Print every fact containing <q> |
-j, --json |
Output JSON |
-v, --version |
Print the version |
-h, --help |
Show help |
Returns one random fact.
- Returns:
string
Returns n unique random facts. Asking for more than count returns every fact, shuffled.
n(number, non-negative integer): How many facts to return.- Returns:
string[] - Throws:
TypeErrorifnis not a non-negative integer.
Returns a deterministic fact for the UTC day of date. Everyone gets the same fact on the same day.
date(Date | number | string): Any valuenew Date()accepts.- Returns:
string - Throws:
TypeErrorfor an invalid date.
Returns every fact containing term, ignoring case. A blank term returns [].
term(string): Text to look for.- Returns:
string[]
Every bundled fact, as a frozen array (readonly string[]).
The number of bundled facts (number).
The v1 API. Resolves to { text } and, if given, calls callback(null, { text }).
- Returns:
Promise<{ text: string }>
v1 fetched facts from cat-fact.herokuapp.com. That API no longer responds, so v1 fails on every call. v2 bundles the facts instead.
catFacts(cb)still works. The result now only has atextfield; other fields from the old API response are gone.node-fetchis no longer installed.- Node.js 18 or later is required.
Live playground: https://gykh.sylvesterdas.com/cat-facts/
Draw random facts, see today's fact, search every fact and share your favorite, entirely in your browser. To run it offline, open docs/index.html locally.
If you find this library useful, check out MiniFyn, the simplest way to shorten, share, and track your links, and its family of privacy-focused tools:
| Product | What it does | Link |
|---|---|---|
| π MiniFyn | Shorten, share and track links with the short mnfy.in domain |
minifyn.com |
| π§© MiniFyn API | Add link shortening and analytics to your own apps | API docs |
| π‘οΈ ScamGuard | Check links and QR codes for scams, phishing and malware | minifyn.com/scamguard Β· Chrome extension |
| π CensorFyn | Offline, on-device AI redaction for photos and videos | minifyn.com/censorfyn |
| π¬ ClipFyn | Trim and prepare videos for sharing | minifyn.com/clipfyn |
- Sylvester Das β Website β’ MiniFyn β’ Buy Me A Coffee
MIT Β© 2021-2026 get-your-knowledge-here
