No description
Find a file
2025-10-16 13:39:29 +02:00
routes feat(init): german random word api 2025-08-21 16:01:15 +03:00
scripts feat(init): german random word api 2025-08-21 16:01:15 +03:00
services feat(init): german random word api 2025-08-21 16:01:15 +03:00
utils feat(init): german random word api 2025-08-21 16:01:15 +03:00
.dockerignore feat(docker): add Dockerfile and docker-compose for containerized deployment 2025-10-14 16:06:55 +03:00
.gitignore feat(init): german random word api 2025-08-21 16:01:15 +03:00
docker-compose.yml feat(docker): add Dockerfile and docker-compose for containerized deployment 2025-10-14 16:06:55 +03:00
Dockerfile feat(docker): add Dockerfile and docker-compose for containerized deployment 2025-10-14 16:06:55 +03:00
justfile feat(justfile): add deployment commands for Docker setup of German Word API 2025-10-16 13:39:29 +02:00
package-lock.json feat(init): german random word api 2025-08-21 16:01:15 +03:00
package.json feat(init): german random word api 2025-08-21 16:01:15 +03:00
README.md feat(docker): add Dockerfile and docker-compose for containerized deployment 2025-10-14 16:06:55 +03:00
server.js feat(init): german random word api 2025-08-21 16:01:15 +03:00

German Words API

A REST API that serves random German words with difficulty filtering based on frequency data from external sources.


Features

  • Random German word generation
  • Difficulty filtering (beginner, intermediate, advanced)
  • Word search functionality
  • Word statistics and metadata
  • External data source integration
  • Rate limiting and security headers
  • Data refresh capabilities

Quick Start

Prerequisites

  • Docker and Docker Compose installed

Steps

  1. Fetch German word data (required for first run)
npm install
npm run fetch-data
  1. Build and run with Docker Compose
docker compose up -d
  1. Visit the API

Docker Commands

# Start the container
docker compose up -d

# Stop the container
docker compose down

# View logs
docker compose logs -f

# Rebuild the image
docker compose up -d --build

Option 2: Local Development

  1. Install dependencies
npm install
  1. Fetch German word data (required for first run)
npm run fetch-data

This will take a few minutes as it fetches data from external APIs.

  1. Start the server
npm start

Or for development (with auto-reload):

npm run dev
  1. Visit the API

API Endpoints

GET /api/words/random

Get random German words with optional filtering.

Parameters:

  • count (150) → number of words to return (default: 1)
  • difficultybeginner, intermediate, or advanced
  • typenoun, verb, adjective, etc.

Example:

GET /api/words/random?count=5&difficulty=beginner

Search German words by German or English text.

Parameters:

  • q (required) → search query (minimum 2 characters)
  • limit → maximum results (default: 10)

Example:

GET /api/words/search?q=haus&limit=5

GET /api/words/difficulties

Get available difficulty levels.


GET /api/words/types

Get available word types.


GET /api/words/stats

Get word database statistics.


POST /api/words/refresh

Refresh word data from external sources.


Data Sources


Project Structure

German-api/
├── package.json           # Dependencies and scripts
├── server.js              # Main Express server
├── services/
│   └── dataFetcher.js     # External API integration
├── scripts/
│   └── fetchData.js       # Data fetching script
├── utils/
│   └── wordProcessor.js   # Word processing logic
├── routes/
│   └── words.js           # API endpoints
├── data/
│   └── german-words.json  # Generated word database
└── README.md

Setup Instructions

  1. Run npm install to install dependencies
  2. Run npm run fetch-data to populate the word database
  3. Run npm start to start the API server

The API will be available at: http://localhost:3000


License

MIT