Overview

The StudyFetch API allows you to generate various types of study materials using AI. You can:
  • Generate outlines for structured learning
  • Create comprehensive study notes
  • Build topic overviews
  • Generate concise summaries
  • Customize content length and education level
  • Organize generated materials into folders

Generate Material

Generate study materials from a topic. This method returns immediately with the material ID while generation happens asynchronously.
const material = await client.v1.materials.generate({
  name: 'Photosynthesis Study Notes',
  topic: 'Photosynthesis in plants',
  type: 'notes',
  context: 'Focus on light and dark reactions, chloroplast structure',
  level: 'college',
  length: 'medium',
  folderId: 'folder_123abc'
});

console.log('Material ID:', material._id);
console.log('Status:', material.status); // 'processing'

Generate Parameters

name
string
required
Name for the generated material
topic
string
required
Topic or context to generate material from
type
string
required
Type of material to generate:
  • outline - Structured hierarchical breakdown
  • overview - High-level introduction to topic
  • notes - Detailed study notes with explanations
  • summary - Concise summary of key points
context
string
Additional context or details about the topic
folderId
string
Target folder ID to organize the material
length
string
default:"medium"
Length of the generated content:
  • short - Brief content (1-2 pages)
  • medium - Standard length (3-5 pages)
  • long - Comprehensive content (6+ pages)
level
string
default:"college"
Target education level:
  • high_school - Basic concepts, simpler language
  • college - Standard academic level
  • professional - Advanced, technical content

Response

{
  "_id": "material_789ghi",
  "name": "Photosynthesis Study Notes",
  "type": "notes",
  "contentType": "generated",
  "topic": "Photosynthesis in plants",
  "generationType": "notes",
  "status": "processing",
  "content": null,
  "wordCount": 0,
  "organizationId": "org_456def",
  "folderId": "folder_123abc",
  "level": "college",
  "length": "medium",
  "createdAt": "2024-01-20T14:30:00Z",
  "updatedAt": "2024-01-20T14:30:00Z"
}

Generate and Process Material

Generate materials and wait for processing to complete. This method polls until the material is ready or times out.
const material = await client.v1.materials.generateAndProcess({
  name: 'Complete Biology Notes',
  topic: 'Cell division and mitosis',
  type: 'notes',
  level: 'college',
  length: 'long',
  pollIntervalMs: 2000,  // Check every 2 seconds
  timeoutMs: 300000      // Wait up to 5 minutes
});

console.log('Material ready!');
console.log('Word count:', material.wordCount);
console.log('Content preview:', material.content.substring(0, 200));

Generate and Process Parameters

All parameters from generate() plus:
pollIntervalMs
integer
default:"2000"
Polling interval in milliseconds to check if material is ready
timeoutMs
integer
default:"300000"
Maximum time to wait for processing in milliseconds (default: 5 minutes)

Response

{
  "_id": "material_789ghi",
  "name": "Complete Biology Notes",
  "type": "notes",
  "contentType": "generated",
  "topic": "Cell division and mitosis",
  "generationType": "notes",
  "status": "completed",
  "content": "# Cell Division and Mitosis\n\n## Introduction\n\nCell division is a fundamental process...",
  "wordCount": 2450,
  "organizationId": "org_456def",
  "folderId": null,
  "level": "college",
  "length": "long",
  "createdAt": "2024-01-20T14:30:00Z",
  "updatedAt": "2024-01-20T14:31:45Z"
}

Complete Workflow Example

Here’s a complete example of generating and organizing study materials for a course:
// 1. Create a folder for the course
const courseFolder = await client.v1.folders.create({
  name: 'Biology 101 - Spring 2024'
});

// 2. Generate course outline
const outline = await client.v1.materials.generateAndProcess({
  name: 'Biology 101 Course Outline',
  topic: 'Introduction to Biology for first-year students',
  type: 'outline',
  folderId: courseFolder._id,
  level: 'college',
  length: 'long'
});

console.log('Course outline generated:', outline.name);

// 3. Generate chapter materials
const chapters = [
  { name: 'Cell Biology', topic: 'Cell structure, organelles, and functions' },
  { name: 'Genetics', topic: 'DNA, RNA, heredity, and gene expression' },
  { name: 'Evolution', topic: 'Natural selection, speciation, and evidence' }
];

const chapterMaterials = await Promise.all(
  chapters.map(chapter => 
    client.v1.materials.generate({
      name: `${chapter.name} - Study Notes`,
      topic: chapter.topic,
      type: 'notes',
      folderId: courseFolder._id,
      level: 'college',
      length: 'medium',
      context: 'Include diagrams descriptions and key terminology'
    })
  )
);

console.log(`Generated ${chapterMaterials.length} chapter materials`);

// 4. Generate quick summaries for review
const summaries = await Promise.all(
  chapters.map(chapter =>
    client.v1.materials.generateAndProcess({
      name: `${chapter.name} - Quick Review`,
      topic: chapter.topic,
      type: 'summary',
      folderId: courseFolder._id,
      level: 'college',
      length: 'short'
    })
  )
);

// 5. List all materials in the folder
const allMaterials = await client.v1.materials.list({
  folderId: courseFolder._id
});

console.log('\nCourse materials:');
allMaterials.forEach(material => {
  console.log(`- ${material.name} (${material.generationType || material.contentType})`);
});