TellaAI
API Reference/Core Content

Flashcards API

Flashcard generation and retrieval endpoints

Flashcards API

The Flashcards API allows users to generate flashcards using AI from course materials and notes, and retrieve existing flashcard sets. Flashcards are automatically generated from your study materials to help with learning and retention.

Flashcard Set Model

  • id: Unique flashcard set identifier (string)
  • title: Flashcard set title (string)
  • description: Set description (string, optional)
  • difficulty: Difficulty level (string: "EASY" | "MEDIUM" | "HARD")
  • courseId: Associated course ID (string)
  • createdAt: ISO datetime when created (string)
  • updatedAt: ISO datetime when last updated (string)
  • userId: Owner user ID (string)
  • flashcards: Array of flashcard objects

Flashcard Model

  • id: Unique flashcard identifier (string)
  • front: Front side content (string)
  • back: Back side content (string)
  • order: Display order in set (number)
  • flashcardSetId: Parent set ID (string)

Endpoints

All flashcard endpoints require authentication and are scoped to the authenticated user.

Get All Flashcards

Retrieve all flashcard sets for the authenticated user with optional filtering.

GET /api/flashcards

# Filter by course
GET /api/flashcards?courseId=course_abc123

# Filter by flashcard set
GET /api/flashcards?flashcardSetId=flashcard_set_xyz789

Query Parameters

  • courseId: Filter flashcards by specific course ID (optional)

Get Flashcards for Note

Retrieve all flashcard sets associated with a specific note.

GET /api/notes/{noteId}/flashcards

Path Parameters

  • noteId: ID of the note to get flashcards for (required, string)

Response (200)

{
  "success": true,
  "data": [
    {
      "id": "flashcard_set_abc123",
      "title": "Cell Structure Flashcards",
      "description": "Key terms and concepts from cell biology lecture",
      "difficulty": "MEDIUM",
      "courseId": "course_abc123",
      "noteId": "note_abc123",
      "createdAt": "2024-01-01T00:00:00.000Z",
      "updatedAt": "2024-01-01T00:00:00.000Z",
      "userId": "user_123",
      "course": {
        "id": "course_abc123",
        "name": "Biology 101"
      },
      "note": {
        "id": "note_abc123",
        "title": "Biology Lecture: Cell Structure"
      },
      "flashcards": [
        {
          "id": "flashcard_abc123",
          "front": "What is the powerhouse of the cell?",
          "back": "Mitochondria",
          "order": 1,
          "flashcardSetId": "flashcard_set_abc123"
        }
      ]
    }
  ],
  "message": "Note flashcards retrieved successfully"
}

Errors:

  • 401: Authentication required
  • 404: Note not found or access denied

Generate Flashcards with AI

Generate new flashcards using AI based on course materials and notes.

POST /api/flashcards/generate
Content-Type: application/json

{
  "courseId": "course_abc123",
  "noteIds": ["note_123", "note_456", "note_789"],
  "cardCount": 20
}

Request Body Parameters

  • courseId: ID of the course to generate flashcards for (required, string)
  • noteIds: Array of specific note IDs to use for flashcard generation (required, array of strings)
  • cardCount: Number of flashcards to generate (optional, number, default: 10)

Response (201)

{
  "success": true,
  "data": {
    "flashcardSet": {
      "id": "flashcard_set_abc123",
      "title": "Generated Flashcards: Biology Fundamentals",
      "description": "AI-generated flashcards from course notes",
      "difficulty": "MEDIUM",
      "courseId": "course_abc123",
      "noteId": "note_123",
      "createdAt": "2024-01-01T00:00:00.000Z",
      "updatedAt": "2024-01-01T00:00:00.000Z",
      "userId": "user_123"
    },
    "flashcards": [
      {
        "id": "flashcard_abc123",
        "front": "What is the basic unit of life?",
        "back": "The cell",
        "order": 1,
        "flashcardSetId": "flashcard_set_abc123"
      },
      {
        "id": "flashcard_def456",
        "front": "What organelle controls cell activities?",
        "back": "The nucleus",
        "order": 2,
        "flashcardSetId": "flashcard_set_abc123"
      }
    ]
  },
  "message": "Flashcards generated successfully"
}

Errors:

  • 400: Invalid input data, missing course, or invalid note IDs
  • 401: Authentication required
  • 404: Course or notes not found

Get Flashcard Set by ID

Retrieve a specific flashcard set by its ID with all flashcards.

GET /api/flashcards/{id}

Path Parameters

  • id: ID of the flashcard set to retrieve (required, string)

Response (200)

{
  "success": true,
  "data": {
    "id": "flashcard_set_abc123",
    "title": "Biology Chapter 1 Flashcards",
    "description": "Key terms and concepts from cell biology",
    "difficulty": "MEDIUM",
    "courseId": "course_abc123",
    "noteId": "note_123",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-01-01T00:00:00.000Z",
    "userId": "user_123",
    "course": {
      "id": "course_abc123",
      "name": "Biology 101"
    },
    "note": {
      "id": "note_123",
      "title": "Biology Lecture: Cell Structure"
    },
    "flashcards": [
      {
        "id": "flashcard_abc123",
        "front": "What is the basic unit of life?",
        "back": "The cell",
        "order": 1,
        "flashcardSetId": "flashcard_set_abc123"
      }
    ]
  },
  "message": "Flashcard set retrieved successfully"
}

Errors:

  • 401: Authentication required
  • 404: Flashcard set not found

Delete Flashcard Set

Delete a flashcard set and all its flashcards.

DELETE /api/flashcards/{id}

Path Parameters

  • id: ID of the flashcard set to delete (required, string)

Response (200)

{
  "success": true,
  "message": "Flashcard set deleted successfully"
}

Errors:

  • 401: Authentication required
  • 404: Flashcard set not found

Usage Examples

Generate Flashcards from Notes

// Generate flashcards from specific notes in a course
const response = await fetch('/api/flashcards/generate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your-token'
  },
  body: JSON.stringify({
    courseId: 'course_abc123',
    noteIds: ['note_123', 'note_456'],
    cardCount: 15
  })
});

const result = await response.json();
console.log('Generated flashcard set:', result.data.flashcardSet.id);
console.log('Number of flashcards:', result.data.flashcards.length);

Get Flashcards for a Note

// Get all flashcard sets for a specific note
const response = await fetch('/api/notes/note_123/flashcards', {
  headers: {
    'Authorization': 'Bearer your-token'
  }
});

const flashcards = await response.json();
console.log('Flashcard sets for note:', flashcards.data.length);

Study with Flashcards

// Get a specific flashcard set
const flashcardResponse = await fetch('/api/flashcards/flashcard_set_abc123', {
  headers: {
    'Authorization': 'Bearer your-token'
  }
});

const flashcardSet = await flashcardResponse.json();
const flashcards = flashcardSet.data.flashcards;

// Study logic
let currentCard = 0;
function showNextCard() {
  if (currentCard < flashcards.length) {
    const card = flashcards[currentCard];
    console.log('Front:', card.front);
    // Show back after user input
    setTimeout(() => console.log('Back:', card.back), 2000);
    currentCard++;
  }
}

AI Generation Features

Content Analysis

  • Key Concept Extraction: Identifies important terms and concepts from notes
  • Question-Answer Pairs: Creates effective front/back combinations
  • Difficulty Assessment: Automatically adjusts complexity based on content
  • Context Preservation: Maintains educational context from source material

Quality Assurance

  • Relevance Scoring: Flashcards directly relate to source material
  • Clarity Optimization: Questions are clear and unambiguous
  • Duplicate Prevention: Avoids similar or redundant flashcards
  • Educational Value: Focuses on learning objectives and key concepts

Deduplication

  • Note-Specific: Prevents multiple flashcard sets for the same note
  • Content-Based: Checks for existing sets with similar content
  • User-Scoped: Deduplication is per user and course
  • Idempotent: Multiple requests return the same existing set

Integration Notes

  • Flashcards are automatically organized by course and note
  • Generated content integrates with the universal search system
  • AI generation respects course context and difficulty level
  • All flashcard operations are scoped to the authenticated user
  • Note-specific endpoints provide efficient access to related flashcards
  • Deduplication prevents multiple flashcard sets for the same note content