QuizGenie allows users to generate quizzes based on text provided directly or by scraping text from a webpage URL. The application currently supports two main endpoints.
- POST /text
- POST /url
This endpoint accepts a JSON object containing text data. It generates a quiz based on the provided text.
-
Request URL:
http://localhost:3000/text -
Method:
POST -
Content-Type:
application/json -
Request Body:
{ "text": "Your text here" } -
Response:
{ "quiz": { "title": "Quiz Title", "questions": [ { "question": "Question 1?", "answer": "Answer 1" }, { "question": "Question 2?", "answer": "Answer 2" } // More questions... ] } }
This endpoint accepts a JSON object containing a URL. It scrapes text content from the provided URL and generates a quiz based on the scraped text.
-
Request URL:
http://localhost:3000/url -
Method:
POST -
Content-Type:
application/json -
Request Body:
{ "url": "https://example.com/page" } -
Response:
{ "quiz": { "title": "Quiz Title", "questions": [ { "question": "Question 1?", "answer": "Answer 1" }, { "question": "Question 2?", "answer": "Answer 2" } // More questions... ] } }
For TypeScript users, here are the interfaces for the response data:
interface QuizQuestion {
question: string;
answer: string;
}
interface QuizResponse {
title: string;
questions: QuizQuestion[];
}git clone https://github.com/MaxAndreasLundin/QuizGenie
cd quizgenieCreate a .env file in the root directory with the following content:
QUIZGENIE_OPENAI_API_KEY=your_openai_api_keyInstallation instructions for Docker: https://docs.docker.com/compose/install/
docker compose builddocker compose upInstallation instructions for Bun: https://bun.sh/docs/installation
Install dependencies.
bun installTo start the server.
bun startUse a tool like curl, Postman, or any HTTP client to send POST requests to the endpoints.
Examples POST /text Example
curl -X POST http://localhost:3000/text \
-H "Content-Type: application/json" \
-d '{
"text": "Volvo CE is a leading international manufacturer of premium construction equipment..."
}'POST /url Example
curl -X POST http://localhost:3000/url \
-H "Content-Type: application/json" \
-d '{
"url": "https://en.wikipedia.org/wiki/Volvo_Construction_Equipment"
}'Ensure the text provided is substantial enough for quiz generation. For the /url endpoint, the scraper targets common content elements to work across various websites.