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!
Features:
- Simple, intuitive endpoints (
/words,/quotes,/colors) - Random item generation for dynamic content
- Bulk fetching with custom counts
- Docker-ready for instant deployment
- TypeScript + Deno for modern development
- Interactive API documentation at root
Try it now:
# Get a random inspirational quote
curl https://fourapi.onrender.com/quotes/random
# Fetch 2 random color palettes
curl https://fourapi.onrender.com/colors/random/2Quick Start: deno task dev or docker run -p 4040:4040 --rm 4-api-server
-
Install dependencies (Deno handles this automatically)
-
Start the server:
deno task dev
OR
deno run -A main.ts
-
Visit http://localhost:4040/ to view the API documentation.
The 4-API Server provides simple endpoints for fetching words, quotes, and colors.
It supports retrieving all items, random items, items by ID, and multiple random items.
-
Build the Docker image:
docker build -t 4-api-server .OR
docker build --no-cache -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.
The 4-API Server provides simple endpoints for fetching words, quotes, and colors.
It supports retrieving all items, random items, items by ID, and multiple random items.
Available Methods
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
{
"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
{
"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
{
"id": 1,
"bg": "#f4f0ea",
"color": "#544b43"
}Make HTTP requests to the provided endpoints using your preferred client (e.g., curl, Postman, or in your frontend application).
Example:
# Fetch a random word
curl http://localhost:4040/words/random4-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
Clone the repository and start the server:
git clone https://github.com/MalindiFrank/4Api.git
cd 4api
deno task devServer will start locally at:
http://localhost:4040