stoicism-api-client
v1.1.1
Published
A lightweight JavaScript client for fetching Stoic quotes from the Stoic Quote Public API.
Maintainers
Readme
stoicism-api-client
stoicism-api-client is a lightweight, zero-dependency JavaScript client that makes it easy to fetch Stoic quotes from a public API. Ideal for learning projects, bots, motivational apps, and philosophy enthusiasts.
📦 Installation
npm install stoicism-api-client🎲 Features
- Fetch random Stoic quotes: Retrieve timeless wisdom from Stoic philosophers like Marcus Aurelius, Seneca, and Epictetus.
- Lightweight & Fast: Minimal implementation with no unnecessary overhead.
- Zero dependencies: No external libraries required — uses native web APIs.
- Simple API surface: One function, one responsibility. Easy to learn and use.
- Type-safe (TypeScript support): Includes TypeScript typings for better developer experience.
- Beginner-friendly: Ideal for learning projects, demos, bots, and motivational apps.
## ⚠️ Important: ##
This API cannot be accessed directly from the browser due to CORS restrictions enforced by the source API.
This package is intended to be used in server-side environments such as Node.js and other backend frameworks.🔤 Example Usage
- Get A Random Stoic Quote
import { getStoicQuote } from "stoicism-api-client";
async function run() {
const response = await getStoicQuote();
if (response.code === "api-ok" && response.payload) {
console.log(response.payload);
} else {
console.error(response.message);
}
}
run();
// 200:OK
/*
{
"code": "api-ok",
"message": "No errors encountered",
"payload": {
"author": "Epictetus",
"quote": "It’s not what happens to you, but how you react to it that matters."
}
}
*/
// Error
/*
{
"code": "api-fail",
"message": "Get Stoic Quote: Encountered Error!",
"payload": null
}
*/📗 Test Coverage
PASS src/get-stoic-quote/test/index.test.ts
getStoicQuote
✓ returns api-ok when response ok
✓ returns expected payload when response ok
✓ returns api-fail when response.ok is false
✓ returns api-fail when fetch throws
✓ targets the stoic quote endpoint
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Snapshots: 0 total----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------📘 Contributing
Contributions, suggestions, and improvements are welcome. Feel free to open issues or pull requests.
🔒 Security & Privacy
- This package is open source and intended to provide reusable utilities for application development. It does not collect, store, transmit, sell, or share user data, and it does not include analytics, tracking, telemetry, cookies, local storage usage, backend services, or project-owned data collection mechanisms.
- For more details, including vulnerability reporting guidance and consumer security recommendations, please see the Security Policy.
❤️ Support
Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
