Live Sites Using This API:
- 4 Words -
- 4 Phrases -
Visit - fourapi - to view the API documentation.
A light REST API built with Deno & Hono that serves curated collections of
words, quotes, and colors. For developers building creative apps, learning
projects, or needing quick access to inspiring content, prototypes, or adding
some personality to your next project! Simply provides endpoints for fetching
words, quotes, and color pallets. It supports retrieving all items, random
items, items by ID, and multiple random items.
Quick Try - On The Terminal:
# Get a random inspirational quote
curl https://fourapi.onrender.com/quotes/random
# Fetch 2 random color palettes
curl https://fourapi.onrender.com/colors/random/2git clone https://github.com/MalindiFrank/4api.git
cd 4api
deno task devdeno task dev or docker run -p 4040:4040 --rm 4-api-server
Visit http://localhost:4040/ to view the API documentation.
-
Build the Docker image:
docker build -t 4-api-server . -
Run the container:
docker run -p 4040:4040 --rm --name 4-api 4-api-server
-
Visit http://localhost:4040/ to access the API.
Available Methods + Routes for each collection (quotes, colors, words)
Each collection's get-method usage example:
GET /<collection>→ all items + countGET /<collection>/:id→ one item by IDGET /<collection>/random→ one random itemGET /<collection>/random/:n→ n random items + count
- Base URL:
/words - Description: Fetch words along with their definition and grammatical figure.
Available Methods
GET /words→ Fetch all wordsGET /words/2→ Fetch a word where it's id = 2GET /words/random→ Fetch a random wordGET /words/random/5→ Fetch 5 random words
Sample Response
{
"status": "OK",
"data": [
{
"id": 1,
"name": "phosphenes",
"figure": "n.",
"definition": "the colors or 'stars' you see when you rub your eyes"
}
]
}- Base URL:
/quotes - Description: Fetch inspirational quotes with authors.
Available Methods
GET /quotes→ Fetch all quotesGET /quotes/random→ Fetch a random quoteGET /quotes/:id→ Fetch a quote by its IDGET /quotes/random/:count→ Fetch a certain number of random quotes
Sample Response
{
"status": "OK",
"data": [
{
"id": 1,
"quote": "Dreaming, after all, is a form of planning",
"author": "Gloria Steinem"
}
]
}- Base URL:
/colors - Description: Fetch color pairs with background and text values.
Available Methods
GET /colors→ Fetch all colorsGET /colors/random→ Fetch a random colorGET /colors/:id→ Fetch a color by its IDGET /colors/random/:count→ Fetch a certain number of random colors
Sample Response
{
"status": "OK",
"data": [
{
"id": 1,
"bg": "#f4f0ea",
"color": "#544b43"
}
]
}4-api-server/
├── public/
│ └── index.html
├── src/
│ ├── app.ts # Hono app bootstrap
│ ├── controller/ # route logic
│ ├── middlewares/ # request validation, error handling
│ ├── models/ # data models (TypeScript interfaces)
│ ├── routes/ # API routes (mount controllers)
│ ├── services/ # business logic
│ ├── utils/ # helpers
│ └── db/ # JSON data storage files
├── tests/
├── main.ts # entry point
└── deno.json # Deno configuration
Deno Runtime-Hono Framework-TypeScript-JSON-based storage