Complete reference for all API endpoints, request/response formats, and usage examples.
http://localhost:3000
All endpoints are currently unauthenticated. The API key for Gemini is managed server-side via environment variables.
All endpoints return JSON responses with consistent structure:
{
"success": true,
"data": { /* endpoint-specific data */ },
"error": null
}Or on error:
{
"success": false,
"data": null,
"error": "Error message describing what went wrong"
}Identifies matching categories from a provided list based on semantic analysis of title and description.
{
"title": "Understanding Kant's Critique of Pure Reason",
"description": "A comprehensive analysis of Kant's philosophical work and its implications for modern epistemology",
"categories": ["Philosophy", "Metaphysics", "History", "Science", "Politics"]
}| Parameter | Type | Required | Description |
|---|---|---|---|
title |
string | Yes | Title of the content |
description |
string | Yes | Description of the content |
categories |
string[] | Yes | List of categories to match against (min 1, typically 3-5) |
{
"success": true,
"data": {
"matchingCategories": ["Philosophy", "Metaphysics"],
"totalCategoriesProvided": 5
},
"error": null
}| Field | Type | Description |
|---|---|---|
matchingCategories |
string[] | Up to 3 categories that best match the content |
totalCategoriesProvided |
number | Count of categories provided in request |
Example 1: Academic Content
curl -X POST http://localhost:3000/identifyCategories \
-H "Content-Type: application/json" \
-d '{
"title": "Machine Learning Fundamentals",
"description": "Learn the basics of ML algorithms, neural networks, and data preprocessing techniques",
"categories": ["Technology", "Science", "Education", "Business", "Health"]
}'Response:
{
"success": true,
"data": {
"matchingCategories": ["Technology", "Science", "Education"],
"totalCategoriesProvided": 5
},
"error": null
}Example 2: Hebrew Categories
curl -X POST http://localhost:3000/identifyCategories \
-H "Content-Type: application/json" \
-d '{
"title": "הלכות שבת",
"description": "חקירה מעמיקה בהלכות השבת כפי שהובאו בשולחן ערוך",
"categories": ["חכמה", "הלכה", "תנ״ך", "עברית", "דת"]
}'Missing Required Field:
{
"success": false,
"data": null,
"error": "Validation failed: categories is required"
}Empty Categories:
{
"success": false,
"data": null,
"error": "Validation failed: categories must not be empty"
}Gemini API Error:
{
"success": false,
"data": null,
"error": "Failed to identify categories: [Gemini error message]"
}Analyzes title and description to provide insights. Optionally generates YouTube-style description.
{
"title": "The Evolution of Artificial Intelligence",
"description": "From early AI research to modern deep learning breakthroughs",
"isYoutube": false
}| Parameter | Type | Required | Description |
|---|---|---|---|
title |
string | Yes | Content title |
description |
string | Yes | Content description |
isYoutube |
boolean | No | If true, generates YouTube-style analysis (default: false) |
Standard Mode:
{
"success": true,
"data": {
"analysis": "This content covers the comprehensive history and evolution of artificial intelligence...",
"keyTopics": ["AI", "Deep Learning", "History", "Technology"],
"contentType": "Educational"
},
"error": null
}YouTube Mode (isYoutube: true):
{
"success": true,
"data": {
"analysis": "This video explores the fascinating journey of AI development...",
"youtubeDescription": "In this video, we dive deep into the evolution of artificial intelligence, exploring how the field has transformed from early theoretical research to today's cutting-edge deep learning systems. We'll examine key milestones, influential researchers, and breakthrough technologies that shaped modern AI.",
"keyTopics": ["AI", "Deep Learning", "Machine Learning", "Technology"],
"contentType": "Educational"
},
"error": null
}Example 1: Standard Analysis
curl -X POST http://localhost:3000/analyzeStaticData \
-H "Content-Type: application/json" \
-d '{
"title": "Quantum Computing Basics",
"description": "Introduction to quantum bits, superposition, and quantum gates",
"isYoutube": false
}'Example 2: YouTube-Style Analysis
curl -X POST http://localhost:3000/analyzeStaticData \
-H "Content-Type: application/json" \
-d '{
"title": "Quantum Computing Basics",
"description": "Introduction to quantum bits, superposition, and quantum gates",
"isYoutube": true
}'Analyzes YouTube video descriptions and identifies matching categories.
{
"videoDescription": "In this episode, we explore the philosophical foundations of consciousness, examining theories from Descartes, Kant, and modern neuroscience...",
"categories": ["Philosophy", "Science", "History", "Psychology", "Education"]
}| Parameter | Type | Required | Description |
|---|---|---|---|
videoDescription |
string | Yes | The YouTube video description to analyze |
categories |
string[] | Yes | Categories to match against |
{
"success": true,
"data": {
"matchingCategories": ["Philosophy", "Science", "Psychology"],
"description": "This video discusses philosophical and scientific perspectives on consciousness",
"totalCategoriesProvided": 5
},
"error": null
}curl -X POST http://localhost:3000/analyzeYouTubeVideo \
-H "Content-Type: application/json" \
-d '{
"videoDescription": "Learn about the history of philosophy from Socrates to Nietzsche, with special focus on epistemology and ethics.",
"categories": ["Philosophy", "History", "Education", "Religion", "Science"]
}'Generates generic flashcards from any content using a custom system prompt.
{
"content": "Photosynthesis is the process by which plants convert light energy into chemical energy stored in glucose...",
"systemPrompt": "Create educational flashcards with concise questions on one side and detailed answers on the other.",
"numberOfCards": 5,
"conversationHistory": []
}| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | Yes | The content to generate flashcards from |
systemPrompt |
string | Yes | Instructions for how to generate the flashcards |
numberOfCards |
number | No | Number of cards to generate (default: 5) |
conversationHistory |
object[] | No | Previous conversation turns for context |
Each entry in conversation history should be:
{
"role": "user", // or "assistant"
"content": "Your message here"
}{
"success": true,
"data": {
"flashcards": [
{
"front": "What is photosynthesis?",
"back": "Photosynthesis is the process by which plants convert light energy into chemical energy stored in glucose and oxygen."
},
{
"front": "What are the inputs to photosynthesis?",
"back": "The inputs are carbon dioxide (CO₂), water (H₂O), and light energy from the sun."
},
{
"front": "Where does photosynthesis occur in the plant?",
"back": "Photosynthesis primarily occurs in the chloroplasts of plant cells, specifically in the thylakoid membranes."
}
],
"numberOfCardsGenerated": 3
},
"error": null
}| Field | Type | Description |
|---|---|---|
flashcards |
object[] | Array of flashcard objects |
flashcards[].front |
string | Question or prompt side of the card |
flashcards[].back |
string | Answer or explanation side of the card |
numberOfCardsGenerated |
number | Count of cards actually generated |
Example 1: Science Content
curl -X POST http://localhost:3000/flashcards/generate \
-H "Content-Type: application/json" \
-d '{
"content": "The water cycle involves evaporation, condensation, and precipitation. Water from oceans, lakes, and rivers evaporates due to solar heat, forming water vapor. This vapor rises and condenses into clouds at cooler altitudes. Finally, precipitation returns water to Earth as rain or snow.",
"systemPrompt": "Create 4 clear flashcards about the water cycle.",
"numberOfCards": 4
}'Example 2: With Conversation History
curl -X POST http://localhost:3000/flashcards/generate \
-H "Content-Type: application/json" \
-d '{
"content": "Additional content about advanced water cycle concepts",
"systemPrompt": "Build on previous cards with more advanced concepts",
"numberOfCards": 3,
"conversationHistory": [
{"role": "user", "content": "Create flashcards about the water cycle"},
{"role": "assistant", "content": "Here are the initial cards..."}
]
}'Generates Anki-formatted flashcards specialized for political philosophy.
{
"content": "In 'The Social Contract', Rousseau argues that legitimate political authority derives from a collective agreement where individuals surrender their natural rights to the community...",
"numberOfCards": 5,
"conversationHistory": []
}| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | Yes | Political philosophy content to analyze |
numberOfCards |
number | No | Number of cards (default: 5) |
conversationHistory |
object[] | No | Previous turns for context |
{
"success": true,
"data": {
"flashcards": [
{
"front": "What is Rousseau's concept of the 'general will'?",
"back": "The general will (volonté générale) is the collective consensus of a political community about the common good, representing the true interests of the people rather than individual desires."
},
{
"front": "How does Rousseau's social contract differ from Hobbes?",
"back": "While Hobbes emphasized submission to an absolute sovereign for security, Rousseau argued that legitimate authority must reflect the general will of all citizens, preserving collective freedom."
}
],
"numberOfCardsGenerated": 2,
"domain": "Political Philosophy"
},
"error": null
}curl -X POST http://localhost:3000/anki/philosophy/political/generate \
-H "Content-Type: application/json" \
-d '{
"content": "John Locke proposed the concept of natural rights including life, liberty, and property. He argued that governments are formed by social contract to protect these inherent rights, and that citizens have the right to revolution if the government fails to protect them.",
"numberOfCards": 3
}'Generates Anki-formatted flashcards specialized for Kantian philosophy.
{
"content": "Kant's categorical imperative states that an action is moral only if one can will that it becomes a universal law...",
"numberOfCards": 5,
"conversationHistory": []
}| Parameter | Type | Required | Description |
|---|---|---|---|
content |
string | Yes | Kant philosophy content |
numberOfCards |
number | No | Number of cards (default: 5) |
conversationHistory |
object[] | No | Previous turns for context |
{
"success": true,
"data": {
"flashcards": [
{
"front": "What is Kant's categorical imperative?",
"back": "A moral principle stating that one should act only in accordance with maxims that one can will should become universal laws. It's the foundation of Kant's deontological ethics."
},
{
"front": "Explain Kant's notion of 'thing-in-itself' (Noumenon)",
"back": "The thing-in-itself is reality as it exists independent of human perception. Unlike phenomena (things as they appear to us), noumena cannot be directly known, only inferred."
}
],
"numberOfCardsGenerated": 2,
"domain": "Kant Philosophy"
},
"error": null
}curl -X POST http://localhost:3000/anki/philosophy/kant/generate \
-H "Content-Type: application/json" \
-d '{
"content": "Kant made a distinction between analytic and synthetic judgments. Analytic judgments expand our understanding through logical analysis, while synthetic judgments provide new knowledge about the world. His critical philosophy challenged the notion that all knowledge must be either purely rational or purely empirical.",
"numberOfCards": 4
}'Interactive API documentation using Scalar UI.
Response: HTML page with interactive endpoint explorer
Example:
curl http://localhost:3000/docs
# Opens interactive Scalar UI in browserRaw OpenAPI specification in JSON format.
Response: OpenAPI 3.0.0 specification
Example:
curl http://localhost:3000/docs/json | jq .| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad request (validation error) |
| 500 | Server error (Gemini API error or internal issue) |
The Gemini API has rate limits. Depending on your API tier:
- Free tier: ~60 requests per minute
- Paid tier: Higher limits based on your plan
If rate limited, Gemini returns an error that is caught and returned as a 500 response.
- Keep categories concise (1-5 items typically)
- Use clear, single-word or short-phrase categories
- Categories should be mutually distinguishable for best results
- Works best with content between 100-5000 characters
- Very short content may yield less reliable matches
- Very long content may timeout (consider chunking)
- System prompt heavily influences output quality
- Specific instructions yield better results than generic ones
- Use conversation history for refinement across multiple calls
- Full support for Hebrew and Aramaic
- Include Hebrew categories if analyzing Hebrew content
- The system has built-in knowledge of Jewish texts and concepts
- Always check
successfield in response - Read
errormessage for debugging - Retry logic recommended for rate limit errors (429 would be returned if implemented)
async function identifyCategories(
title: string,
description: string,
categories: string[]
) {
const response = await fetch('http://localhost:3000/identifyCategories', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title, description, categories })
});
const result = await response.json();
if (result.success) {
console.log('Matching categories:', result.data.matchingCategories);
} else {
console.error('Error:', result.error);
}
return result;
}import requests
import json
def generate_flashcards(content, system_prompt, number_of_cards=5):
response = requests.post(
'http://localhost:3000/flashcards/generate',
json={
'content': content,
'systemPrompt': system_prompt,
'numberOfCards': number_of_cards
}
)
data = response.json()
if data['success']:
for card in data['data']['flashcards']:
print(f"Q: {card['front']}")
print(f"A: {card['back']}\n")
else:
print(f"Error: {data['error']}")
return data- Ensure
GOOGLE_API_KEYis set in.env - Verify the key is valid and has Gemini API enabled
- Check that the key has proper permissions
- Review the request body against the required parameters
- Ensure all string fields are non-empty
- Check array fields are not empty
- Gemini API calls can take 2-5 seconds
- Check network connectivity
- Verify server is running (
bun run index.ts)
- Try refining your category list
- Use more specific categories rather than generic ones
- Adjust content title/description for clarity
For more information:
- See README.md for setup instructions
- See CLAUDE.md for AI integration guide
- See ARCHITECTURE.md for system design details
- Visit
http://localhost:3000/docsfor interactive testing