4-API Server

This 4-API allows you to:

Available Methods:

Endpoints

Available Methods

Routes for each collection (quotes, colors, words):


1. Words

Base URL: /words

Description: Fetch words along with their definition and grammatical figure.

Available Methods

Sample JSON 4Words:

{
  "status": "OK",
  "data": [
    {
      "id": 1,
      "name": "phosphenes",
      "figure": "n.",
      "definition": "the colors or 'stars' you see when you rub your eyes"
    }
  ]
}
  

Sample JSON 4Quotes:

{
  "status": "OK",
  "data": [
    {
      "id": 1,
      "quote": "Dreaming, after all, is a form of planning",
      "author": "Gloria Steinem"
    }
  ]
}
  

Sample JSON 4Colors:

{
  "status": "OK",
  "data": [
    {
      "id": 1,
      "bg": "#f4f0ea",
      "color": "#544b43"
    }
  ]
}
  

How to Use This API:

Python Example

import requests
import json

url = "https://fourapi.onrender.com/quotes/random"

response = requests.get(url)
if response.status_code == 200:
    data = response.json()
    print(json.dumps(data, indent=2))
else:
    print("Error:", response.status_code)
  

JavaScript Example (Node.js / Browser)

fetch("https://fourapi.onrender.com/words/random")
  .then(response => response.json())
  .then(data => {
    console.log("Fetched word:");
    console.log(JSON.stringify(data, null, 2));
  })
  .catch(error => console.error("Error:", error));
  

Java Example (with Maven + Unirest)

Add this dependency in your pom.xml:

<dependency>
  <groupId>com.konghq</groupId>
  <artifactId>unirest-java</artifactId>
  <version>3.14.5</version>
</dependency>
  

Example Java code:

import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
import kong.unirest.Unirest;

public class FourApiExample {
    public static void main(String[] args) {
        HttpResponse<JsonNode> response = Unirest.get("https://fourapi.onrender.com/colors/random")
                .asJson();

        System.out.println("Response:");
        System.out.println(response.getBody().toPrettyString());
    }
}