Skip to content

foferys/programmers-facts-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

programming funny quotes

Contributors Java Spring Boot PostgreSQL Git

pp Hugging Face

Description

API REST in sola lettura che espone citazioni/fatti divertenti sui programmatori (tipi: backend, frontend, generic) in JSON. Base URL: http://localhost:8080/api/v1/phrases. Documentazione dettagliata e stato dei miglioramenti: vedi PDR-Programmers-Facts-API.md.

Setup (variabili d'ambiente)

Le credenziali del database non sono nel repository. Prima di avviare l'app o Docker:

  1. Copy .env.example to .env:
    cp .env.example .env (Linux/macOS) or rename/copy by hand on Windows.
  2. Open .env and enter values ​​for:
  • Docker: POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB (required for docker-compose).
  • Local Execution (Spring without Docker): SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME, SPRING_DATASOURCE_PASSWORD (e.g., jdbc:postgresql://localhost:5434/programmers-api if Postgres is running locally on port 5434).

Never commit the .env file (it's in .gitignore).

Key endpoints (base: /api/v1/phrases)

Metodo Endpoint Descrizione
GET /all All sentences
GET /random Una frase casuale
GET /random-explicit A random phrase (404 se no phrase)
GET /{type} Phrases by type (frontend, backend, generic); invalid type → "generic"
GET /by-type?type=backend Phrases for type (query param; type required and valid, otherwise 400)
GET /id/{id} Phrase for ID (404 if nonexistent)
GET /ping Health check (204 No Content)

In case of error the response is JSON: { "error": "...", "code": "400|404|500", "timestamp": "..." }.

Example Usage

curl http://localhost:8080/api/v1/phrases/random

Response:

{
    "data": {
        "id": 24,
        "phrase": "The first rule of debugging: Don’t make it worse.",
        "type": "generic"
    }
}

Advanced Usage

you can retrieve a list of quotes filtered by a specific type (backend, frontend, or generic).

curl http://localhost:8080/api/v1/phrases/by-type?type=backend  

Response

{
    "data": [
        {
            "id": 1,
            "phrase": "Backend developers always say, 'It worked on my local server.'",
            "type": "backend"
        },
        {
            "id": 4,
            "phrase": "Backend developers don’t fear downtime; they fear 'urgent deployments.'",
            "type": "backend"
        }
    ]
}

Dedication

This API serves up quirky quotes that programmers can’t debug away!

my coding backpack in ASCII ART

If you enjoy this api, or just love programming, please donate to:

pp

Contributors ✨

Gianpiero Ferraro
Gianpiero Ferraro(always me lol)

About

An API in Java that will return programmers fun facts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published