Skip to content

NPM-Workbench/stoicism-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

stoicism-banner npm downloads license Security Policy npm_provenance NPM Unpacked Size

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

  1. Fetch random Stoic quotes: Retrieve timeless wisdom from Stoic philosophers like Marcus Aurelius, Seneca, and Epictetus.
  2. Lightweight & Fast: Minimal implementation with no unnecessary overhead.
  3. Zero dependencies: No external libraries required β€” uses native web APIs.
  4. Simple API surface: One function, one responsibility. Easy to learn and use.
  5. Type-safe (TypeScript support): Includes TypeScript typings for better developer experience.
  6. 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

  1. 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

  1. 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.
  2. 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.

About

πŸ—Ώ A lightweight JavaScript client for fetching Stoic quotes from the Stoic Quote Public API (https://github.com/tlcheah2/stoic-quote-lambda-public-api)

Topics

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors